Thursday, June 26, 2008

Math Object in JavaScript

Math Object in JavaScript

round() to round a number
Math.round(0.60) = 1;
Math.round(0.49) = 0;

random() to return a random number between 0 and 1
Math.random()

max() to return the number with the highest value of two specified numbers
Math.max(5,7) = 7
Math.max(-3,-5) = -3

min() to return the number with the lowest value of two specified numbers
Math.min(5,7) = 5
Math.max(-3,-5) = -5

No comments: