The drinks: reference inside the object of the array passengers is not retrieving the ticket: value. How do I refer to the outer objects ticket value from inside the array?
var passengers = [ { name: 'Jane Doloop', paid: true, ticket: 'coach', drinks: [ticketDrinks(this.ticket, 0), ticketDrinks(this.ticket, 1)] },
{ name: 'Dr.Evel', paid: true, ticket: 'firstclass' },
{ name: 'Sue Property', paid: false, ticket: 'firstclass' },
{ name: 'John Funcall', paid: true, ticket: 'coach' } ];
function ticketDrinks(ticket, location1) {
console.log(ticket, location1);
if (ticket == 'firstclass') {
drink1 = 'cola';
drink2 = 'water';
if (location1 == 0) {
return drink1;
} else {
return drink2;
}
} else if (ticket == 'coach') {
drink1 = 'wine';
drink2 = 'champagne';
if (location1 == 0) {
return drink1;
} else {
return drink2;
}
}
return null;
}