This array reduce line is the code I use to get a total.
let arr = [{c:25,q:1},{c:23.99,q:1},{c:32,q:1}];
let chg = arr.reduce((tot,b) => {return tot+b.c*b.q;},0);
I attempt to convert it to cents as per stripe with this code.
parseFloat(chg.toFixed(2)) * 100
And I get this! 8098.999999999999
WTF ♂️
I provided an example.
let arr = [{c:25,q:1},{c:23.99,q:1},{c:32,q:1}];
let chg = arr.reduce((tot,b) => {return tot+b.c*b.q;},0);
console.log(chg);
console.log(parseFloat(chg.toFixed(2)));
console.log(chg.toFixed(2))
console.log(parseFloat(chg.toFixed(2))*100)
console.log(parseFloat("80.99")*100)
console.log((80.99)*100)
Why is JavaScript returning a repeating decimal??