gpt4 book ai didi

javascript - 'variable1/variable2 = NaN' 其中两个变量都是数字 2

转载 作者:行者123 更新时间:2023-11-28 10:46:17 25 4
gpt4 key购买 nike

我不知道在这里要做什么,在尝试自己解决这个问题的过程中,我打印了这个(在 CMD 中):

testData.topics[z].percentageMark :2
testData.topics[z].questions.length :2
typeof(testData.topics[z].percentageMark) :number
typeof (testData.topics[z].questions.length) :number
FINAL : testData.topics[z].percentageMark :NaN

这是代码的结果(对大对象感到抱歉):

console.log("testData.topics[z].percentageMark :" + testData.topics[z].percentageMark);
console.log("testData.topics[z].questions.length :" + testData.topics[z].questions.length);
console.log("typeof(testData.topics[z].percentageMark) :" + typeof (testData.topics[z].percentageMark));
console.log("typeof (testData.topics[z].questions.length) :" + typeof (testData.topics[z].questions.length));
testData.topics[z].percentageMark = ((testData.topics[z].percentageMarks) / (testData.topics[z].questions.length));
console.log("FINAL : testData.topics[z].percentageMark :" + testData.topics[z].percentageMark);

我真的很困惑在这里要做什么,我不明白这里的简单划分怎么行不通。

最佳答案

这里有错别字

(testData.topics[z].percentageMarks)

“百分比”

作为记录,您也可以编写 var topic = testData.topics[z]

只有当您的代码行很长时,像您这样的问题才会变得更容易。

您还可以对齐代码以便于阅读。

关于javascript - 'variable1/variable2 = NaN' 其中两个变量都是数字 2,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42263485/

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