Because .toFixed() retuns a string so you are replacing the number with a string. Simple logging will show you what is happening.
var jsObject = new Object();
jsObject.number = 0;
for(i = 1; i <= 10; i++) {
jsObject.number += 0.1;
console.log(i, "before", jsObject.number, typeof jsObject.number)
jsObject.number = (jsObject.number).toFixed(1);
console.log(i, "after", jsObject.number, typeof jsObject.number)
}
The output will be:
1 before 0.1 number
1 after 0.1 string
2 before 0.10.1 string
"Uncaught TypeError: jsObject.number.toFixed is not a function",
JavaScript does not hold trailing zeros. So if you need them for output, it would be better to do it where you are outputting the number. Or the only other option would be to parseFloat Number it before you add to it.
jsObject.number = Number(jsObject.number) + 0.1;
jsObject.number = parseFloat(jsObject.number) + 0.1;