Please, I need convert String into Float or Double in Javascript. But I don't want it round it. I want just fixed 2 decimal places Number which means input 0.996 return me 0.99 and not 1.
// 1. Convert number to float strip to 2 decimal places
var total = ',996' // (or 0.996 if you want, doesn't matter)
total = Math.round(parseFloat(
total.replace (',', '.')
)).toFixed(2);
console.log ( typeof total );
console.log ( total );
After this, total
is not a number anymore. It's a String with value 1
It's possible to convert string into decimal number with 2 fixed places without rounding?
If you're interested about simple spent manager, I'm programmit it here https://codepen.io/littleTheRabbit/pen/JjYWjRG
Thank you very much for any advice
Best Regards