Welcome to collectivesolver - Programming & Software Q&A. A website you can trust. All programs tested and works. Contact: aviboots(AT)netvision.net.il
BlueHost Web Hosting

Bonsai Boy of New York Bonsai Trees and Accessories

Liquid Web iThemes WordPress Hosting

Ecommerce Software - Best Ecommerce Platform Made for You - Free Trial

DreamHost Web Hosting


getResponse autofunnels

Liquid Web Cloud VPS Hosting

Disclosure We are a professional Information website that receives compensation from some of the links whose we show you with Information. It means that my content may contain affiliate links.

12,168 questions

16,572 answers

573 users

How to work with decimal places after the point in JavaScript

8 Answers

0 votes
var n = 3.457;

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

3 
 
*/

 




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

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

4 
 
*/

 




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

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

4 
 
*/

 




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

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

3.6 
 
*/

 




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

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

3.57 
 
*/

 




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

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

3.569  
 
*/

 




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

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

3.5690 
 
*/

 




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

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

3.56900
 
*/

 




answered Jun 11, 2015 by avibootz
...