Rounding
Last updated
Methods that round a numeric value. They return a new value and never mutate.
.round() → intRounds to the nearest integer.
.round(precision) → numberRounds to precision decimal places.
.floor() → numberRounds down to the nearest integer.
.ceiling() → numberRounds up to the nearest integer.
The method is
.ceiling(), notceil. The standalone function form isceil(n)- see Built-in functions.
log (2.7).round() // 3
log (3.14159).round(2) // 3.14
log (2.1).ceiling() // 3
log (2.9).floor() // 2Last updated