User Id :    Password :      New Member   Forgot Password  
 
Mathematical Methods in JavaScript
Description The following example uses the round() method of the Math object to round a number to the nearest integer.   No. of Views     1274
  Rating     3
Author Najmul Hoda   Posted On     11 Feb 2010
Tags Java Script    

Sample Code   Download Code

The following example uses the round() method of the Math object to round a number to the nearest integer:
document.write(Math.round(5.7));
The code above will result in the following output:
6
The following example uses the random() method of the Math object to return a random number between 0 and 1:
document.write(Math.random());
The code above can result in the following output:
0.2351911203844656
The following example uses the floor() and random() methods of the Math object to return a random number between 0 and 10:
document.write(Math.floor(Math.random()*11));
The code above can result in the following output:
3

About Author

About Author He is a team lead, having 8+ years of experience. He loves writing technical article for .Net developers. Najmul Hoda
No Photo
 
Country United States
Company BirlaSoft
Home Page http://www.magixchat.com

Rate this article

Rating options from poor, fair, good, very good to excelent.  
 

Comments

 
 
Posted By sdfs on 30 Mar 2010 at 04:32 AM
 
Comment
 
 
   
Write your comment here.
Comment
Verification Code