var movies =
[
{name: "In Bruges", rating:"4.7", seen:false},
{name: "Frozen", rating: "4.5", seen:true},
{name: "Lion King", rating:"5", seen:true},
]
for (var i = 0; i < movies.length; i++) {
var result = "You have ";
if(movies.seen === true){
result += "watched ";
}
else{
result += "not seen ";
}
result += "\"" + movies.name + "\" - ";
result += movies.rating + " stars"
console.log(result)
};
You have not seen "undefined" - undefined stars is the result in chrome however you should see You have seen/not seen "movie name" - "rating" stars.
I need to use for loop to print out what each movie I have watched and rating and if I have seen it or not. Question is why is it undefined? Should the code see movies.rating and just substitute the value there? Can some one check my code and help me with my for loop?
if(movies.seen === true)toif(movies[i].seen === true). or useforEachloop.