tofixed

Solutions on MaxInterview for tofixed by the best coders in the world

showing results for - "tofixed"
Mariana
14 Aug 2019
1var int = 10;
2var float = parseFloat(int).toFixed(2);
3console.log(float); // 10.00
Élodie
08 Mar 2020
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 
Philipp
05 Nov 2018
1//round number to 2 digits
2var num = 5.56789;
3var n = num.toFixed(2);