I'm trying to perform a basic calculation in JavaScript that takes a decimal away from a whole number and no matter what I try I keep getting Not a Number (NaN) errors in the console. My starting number is 1000 then for each cycle on a SetInterval function I want to minus 0.1.
this.StartTimer = function () {
var width = 100;
this.QuestionScore = 1000;
var thisQuiz = this;
var elem = document.getElementById("barStatus");
// Set Interval
var timer = setInterval(frame, 30);
function frame() {
if (width <= 0) {
// Move to next Question when timer is up
clearInterval(timer);
elem.style.width = 100 + '%';
if (this.QuestionsGone == 9) {
thisQuiz.GetSummary(this.Type);
} else {
thisQuiz.AnswerQuestion(-1, 0);
}
} else {
// Increase Status Bar Each Interval
width = width - 0.1;
this.QuestionScore = this.QuestionScore - 0.1;
console.log(this.QuestionScore);
this.QuestionScore = Math.ceil(this.QuestionScore * 10) / 10;
console.log(this.QuestionScore);
elem.style.width = width + '%';
}
}
}