can someone explain why I am getting undefined in my loop? I am trying to run a loop that lets me know if its true if i've watched something as well as the rating. What am I doing wrong?
var films = [ { movie: "fast and the furious", rating: 4, seen: true }, { movie:"13 reasons why", rating: 5, seen: true }, { movie:"beaty and the beast", rating: 4, seen: false } ]; films.forEach(function(movie){ var result = "You have "; if(movie.seen) { result += "watched "; } else{ result += "not seen "; } result += "\"" + films.movie + "\" - "; result += films.rating + " stars"; console.log(result); });
movie.movieandmovie.rating.movieinside forEach, if you want to access an item's properties, you'll usemovienotfilms