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

1297


Rating

3

Author

Najmul Hoda 

Posted On

11 Feb 2010

Tags

Java Script 




Sample 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


Country

United States

Company

BirlaSoft

Home Page

http://www.magixchat.com



