// Create movie DB
var movies = [
{
title: "Avengers",
hasWatched: true,
rating: 5
},
{
title: "SpiderMan",
hasWatched: false,
rating: 4
},
{
title: "LightsOut",
hasWatched: true,
rating: 6
}
]
// Print it out
movies
// Print out all of them
movies.forEach(function(movie)){
var result = "You have ";
if(movie.hasWatched){
result += "watched ";
}else{
result += "not seen ";
}
result += "\" + movie.title + "\"-";
result += movie.rating + " stars";
console.log(result);
}
爲什麼我的第一個對象是真實的,但在控制檯打印出「你沒見過‘復仇者’ - 5星」JavaScript中的谷歌控制檯
謝謝你們了我的錯! – Simon