1var int = 10;
2var float = parseFloat(int).toFixed(2);
3console.log(float); // 10.00
1var a = 3.3445;
2var c = a.toFixed(1); console.log(c); /* result ->*/ 3.3
3var g = a.toFixed(4); console.log(g); /* result ->*/ 3.3445
4var g = a.toFixed(7); console.log(g); /* result ->*/ 3.3445000
5 // ^ ^^^^^^^
6/*Syntax ->*/ number.toFixed([digits])
7// like Me ;D . My company : Rnad
1//toFixed() returns a string, with the number written with a specified number of decimals:
2
3let x = 9.656;
4x.toFixed(0);
5x.toFixed(2);
6x.toFixed(4);
7x.toFixed(6);