December 2013
Intermediate to advanced
384 pages
9h 54m
English
var x = 3.4; var y = 3.5; Math.round(x); //returns 3 Math.round(y); //returns 4 Math.ceil(x); //returns 4 Math.ceil(y); //returns 4 Math.floor(x); //returns 3 Math.floor(y); //returns 3
The JavaScript Math object provides three methods to round numbers. The .round() method rounds numbers #.5 up to the next higher integer and numbers #.49999... down to the next lowest integer. The .ceil() always rounds up to the next highest integer. The .floor() always rounds down to the next lowest integer.
Read now
Unlock full access