5 знаков после запятой
const toFixed = (value, precision) => { const power = Math.pow(10, precision || 0); return String(Math.round(value * power) / power); }; console.log(toFixed(0.123456789, 5)); // '0.12346' console.log(toFixed(0.123456789, 2)); // '0.12' console.log(toFixed(2.345, 2)); // '2.35' console.log(toFixed(2.355, 2)); // '2.35'