I have this code in javascript:
var childrenSize = 7;
var flAmt = parseFloat(100);
var amt = parseFloat(flAmt/childrenSize);
//Rounding-off fix
var newAmt = (amt.toFixed(2))*childrenSize;
alert(newAmt);
var excess = 0;
if(newAmt != flAmt)
excess = parseFloat(flAmt - newAmt);
amt = parseFloat(amt) + excess.toFixed(2);
alert(amt);
amt should be 14.25. But instead, it becomes 14.285714285714286-0.03... why?
Also, how can I improve my code?