round
The round function rounds a number to a given precision. Positive
precision rounds to decimal places, negative precision rounds to powers of
ten, and the default precision rounds to the nearest integer.
- @param
number- The number to round. - @param
precision- The precision to round to. Defaults to0. - @returns The rounded number.
Example
round(4.006) // 4
round(4.006, 2) // 4.01
round(4060, -2) // 4100