JavaScript tofixé
var int = 10;
var float = parseFloat(int).toFixed(2);
console.log(float); // 10.00
Programming Is Fun
var int = 10;
var float = parseFloat(int).toFixed(2);
console.log(float); // 10.00
var a = 3.3445;
var c = a.toFixed(1); console.log(c); /* result ->*/ 3.3
var g = a.toFixed(4); console.log(g); /* result ->*/ 3.3445
var g = a.toFixed(7); console.log(g); /* result ->*/ 3.3445000
// ^ ^^^^^^^
/*Syntax ->*/ number.toFixed([digits])
// like Me ;D . My company : Rnad
let x = 9.656;
x.toFixed(0);
x.toFixed(2);
x.toFixed(4);
x.toFixed(6);