尝试用于...循环并添加一个 if/else 语句,并一直说我错过了一个")"


const testScores = {
John : 99,
Jess : 78,
Ryan : 89,
Tom : 62,
Jane: 57,
Ben: 83
};
for (person in testScores){

if (testScores[person] > 90){
console.log("Well done "+ person ". You scored " + testScores[person])
};
else{
console.log(person + " scored " + testScores[person])};
}
  • 首先是打字错误,您忘记在person". You scored "之间添加+
  • 第二,在if块之后使用;,因此,它程序没有编译

const testScores = {
John: 99,
Jess: 78,
Ryan: 89,
Tom: 62,
Jane: 57,
Ben: 83
};
for (person in testScores) {
if (testScores[person] > 90) {
console.log("Well done " + person + ". You scored " + testScores[person]);
} else {
console.log(person + " scored " + testScores[person]);
}
}

相关内容

最新更新