我在這裏試圖弄清楚這個過程中我不知道該怎麼做,我打印出來了(CMD):'變量1 /變量2 = NaN',其中兩個變量都是數字2
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);
我真正感到困惑,在這裏做什麼,我看不出這裏簡單的劃分是行不通的。
第5行代碼...'percentageMarks'!=='percentageMark' –