Floating point arithmetic is error-prone
Javascript cannot accurately do arithmetic with floating point numbers. So do your math with integers first, then convert to decimal.
by Amy L
JavaScript
var a = 0.1;
var b = 0.2;
var c = 0.3;
var total1 = (a + b) + c;
var total2 = a + (b + c);
if (total1 === total2) document.write('<p>EQUAL</p>');
else document.write('<p>NOT EQUAL</p>');
document.write('<p>'+total1+'</p>');
document.write('<p>'+total2+'</p>');