var movie = [
{
title: "Iron Man",
hasWatched: true,
rating: "5.0",
},
{
title: "Mad Max",
hasWatched: false,
rating: "2.0",
}
]
Google表示无法在以下代码块中读取hasWatched属性
function buildString (movie){
var result = "You have ";
if(movie.hasWatched){
result += "watched ";
} else {
result += "not watched ";
}
result += "\"" + movie.title + "\" - ";
result += movie.rating + " stars"
return result;
}
movie.forEach(function(movie){
buildString();
console.log(buildString(movie));
});
答案 0 :(得分:0)
movie.forEach(function(movie){
buildString(movie);
console.log(buildString(movie));
});
您错过了将参数传递给buildString()函数。