As far as I know, 2 + 2 + 2
is the same thing as 2 * 3
. The result of both is 6
. Why it's not like that in JS?
let result = 0;
for (let i = 0; i < 50; i++) {
result += 0.2; //addition
};
console.log(result);
console.log(0.2 * 50); //multiplication
Is there some difference in execution between addition and multiplication in JS? What the cause of this behaviour?