0
 shuttle.seats[j] = [{
        name : PASSENGERS[i].name,
        house : PASSENGERS[i].house
        }];

For chart when I try to access the value of shuttle.seats[j].name I get the value as undefined.

However using console.log, value of PASSENGERS[i].name is correct, therefore it's value is not being inputted correctly into the array.

1

You are over-complicating things a little. First you're creating an array of one object. So the correct way to access the value of name in your example is

shuttle.seats[j][0].name; 

Second, you could simply just set shuttle.seats[j] to a passenger (e.g., PASSENGER[i] assuming i is within the specified range) and access the value of name the way you want

shuttle.seats[j].name;

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .