How to convert number string with max 2 decimal places after the point in JavaScript

2 Answers

0 votes
var n = 3.457;

document.write(n.toFixed(2));
 
/*
run:

3.46 
 
*/

 



answered Jun 11, 2015 by avibootz
0 votes
var n = 3.457;

var s = n.toFixed(2);

document.write(s);
 
/*
run:

3.46 
 
*/

 



answered Jun 11, 2015 by avibootz
...