【发布时间】:2020-07-11 18:57:13
【问题描述】:
正在阅读 MDN 的教程,并希望扩展我遇到此问题的部分。当我运行下面的代码时:
let examScore = 45;
let examHighestScore = 70;
examReport = `You scored ${ examScore }/${ examHighestScore } (${ Math.round((examScore/examHighestScore*100)) }%). ${ examScore >= 49 ? 'Well done, you passed!' : 'Bad luck, you didn\'t pass this time.' }`;
它返回"You scored 45/70 (64%). Bad luck, you didn't pass this time." 当我将新值设置为examScore 时,返回值不会反映新值。
我为examScore 设置了一个新值,然后再次运行examReport,如下所示。
examScore = 60;
examReport;
我期待:
"You scored 60/70 (86%). Well done, you passed!"
我得到的是:
"You scored 45/70 (64%). Bad luck, you didn't pass this time."
我什至检查了examScore,它返回60。
不确定它是开发人员控制台还是 js 问题。任何指导将不胜感激!
【问题讨论】:
-
你没有重新分配
examReport
标签: javascript console