So im trying to make a movie collection by my self, and im lost at adding object to array and later adding values with properties to new added array at the same time. Help would be appreciated. Keep in mind that code isnt finnished yet especially if statement that i want it to add object with values and properties with so im lost in that one, i’ll be working on it for a while since im practising with this too.
var movieCollection = [
{
name: "Spiderman",
year: 1979
},
{
name: "Batman",
year: 1986
},
{
name: "IT",
year: 2017
}
]
var input = prompt("Choose the action");
while (input !== "quit") {
if (input === "add") {
var question = prompt("What do you wish to add?");
var a = {};
var b = movieCollection.push(a);
} else if (input === "list") {
movieCollection.forEach(function (movie) {
console.log(movie);
})
}
var input = prompt("Choose the action");
}
console.log("You exited");