I am trying to add format: "film" to each object in the array but I can't figure it out.
var movie = [
{title: "A Clockwork Orange", year: "1971", raiting: "8.3", genre: "Crime, Drama, Sci-Fi"},
{title: "Full Metal Jacket", year: "1987", raiting: "8.3", genre: " Drama, War"},
{title: "Pulp Fiction", year: "1994", raiting: "8.9", genre: "Crime, Drama"},
{title: "Fight Club", year: "1999", raiting: "8.8", genre: "Drama"},
{title: "Interstellar", year: "2014", raiting: "8.6", genre: "Adventure, Drama, Sci-Fi"}
];
movie.forEach(function () {
movie.format = "film";
});
movie.forEach(function (element) {
console.log(element);
});
for ... inorfor ... ofloop gives you a lot less headache when it comes to scoping.