var电影={标题:“华尔街之狼”,明星:5,看过:假},
{标题:“疯狂狂暴之路”,星星:5,已观看:真},
{标题:“搜索队”,明星:5,已观看:假},
{标题:“布鲁克林九九”,明星:5,已观看:真}
movies.forEach(function(movie){
var result = "You have" ;
if (movie.havewatched)
result += "watched" ;
}else {
result += "not watched";
}
result = result + movie.title + "-" + movie.stars ;
console.log(result)
})发布于 2020-08-09 11:15:20
下面是在if条件下修复缺失的{后的工作代码。
var movies = [ {title : "Wolf of wall street" ,stars : 5 , havewatched : false},
{title : "Mad max fury road" , stars : 5 , havewatched : true},
{title : "search party " , stars : 5 , havewatched : false} ,
{title : "brooklyn nine nine" , stars : 5 , havewatched : true} ]
movies.forEach(function(movie){
var result = "You have" ;
if (movie.havewatched){
result += "watched" ;
}else {
result += "not watched";
}
result = result + movie.title + "-" + movie.stars ;
console.log(result)
})
https://stackoverflow.com/questions/63325413
复制相似问题