Currently, I have two arrays - arrayGuest and arrayRent. They both contain objects with a common field, GuestID. My goal is to create a list that combines fields from both arrays when their guestIDs match.
The structure of the objects is as follows:
class Guest {
guestID: number;
firstName: string;
lastName: string;
panCardNumber: string;
address: string;
city: string;
state: string;
typeOfRoom: string;
}
class Rent {
guestID:number;
amount:number;
dateOfPayment: Date;
}
Below are the samples of the two arrays involved:
let arrayGuests: Array<Guest> = [
{guestID:1,firstName:"Jay",lastName:"Shetty",panCardNumber:"FSDDE2235A",address:"150ft Ring Road",city:"Rajkot",state:"Gujarat", typeOfRoom: roomType.AC},
// other entries omitted for brevity...
]
let rentArray : Array<Rent>= [
{guestID:1,amount:5000,dateOfPayment:new Date("2022-03-01")},
// other entries omitted for brevity...
]
The desired result format would be similar to: GuestID:1, Name : xyz, amount = 5000