I would like to add more properties inside this object:
let flights =
[
{ id: 00, to: 'Bilbao', from: 'Barcelona', cost: 1600, scale: false },
{ id: 01, to: 'New York', from: 'Barcelona', cost: 700, scale: false },
{ id: 02, to: 'Los Angeles', from: 'Madrid', cost: 1100, scale: true },
{ id: 03, to: 'Paris', from: 'Barcelona', cost: 210, scale: false },
{ id: 04, to: 'Roma', from: 'Barcelona', cost: 150, scale: false },
{ id: 05, to: 'London', from: 'Madrid', cost: 200, scale: false },
{ id: 06, to: 'Madrid', from: 'Barcelona', cost: 90, scale: false },
{ id: 07, to: 'Tokyo', from: 'Madrid', cost: 1500, scale: true },
{ id: 08, to: 'Shangai', from: 'Barcelona', cost: 800, scale: true },
{ id: 09, to: 'Sydney', from: 'Barcelona', cost: 150, scale: true },
{ id: 10, to: 'Tel-Aviv', from: 'Madrid', cost: 150, scale: false }
];
What I did is create a variable that stores the data you want to add an then I push it inside flights, like this:
var newFlight = prompt('Introduce the fligth information:');
if (newFlight) {
var obj = new Object(newFlight);
flights.push(obj);
console.log(flights);
}
What I obtain is that:
And then inside the object we have that:
How can I obtain this:
{id: 11, to: "Australia", from: "Madrid", cost: 1000, scale: true}
instead of this:
String {"11,Australia,Madrid,1000,true"}

