gpt4 book ai didi

javascript - 谷歌说代码无效,我的错误在哪里?

转载 作者:行者123 更新时间:2023-12-03 01:34:47 24 4
gpt4 key购买 nike

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));
});

最佳答案

movie.forEach(function(movie){
buildString(movie);
console.log(buildString(movie));
});

You have missed passing argument to the buildString() function.

关于javascript - 谷歌说代码无效,我的错误在哪里?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51120374/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com