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