JSFiddle - React, Tailwind, and code Playground
by samgu
JavaScript
arrondi = 158.5546546546546897984651651651651
function toFixed(num, fixed) {
var re = new RegExp('^-?\\d+(?:\.\\d{0,' + (fixed || -1) + '})?');
return num.toString().match(re)[0];
}
arrondi = toFixed(arrondi, 2);
arrondi = parseFloat(arrondi);
alert( arrondi );