Skip to main content

round()

round(precision, value): number

Rounds a number to a specified precision.

Parameters

precision

number

The precision of the rounded output.

value

number

The value to round.

Returns

number

Throws

Throws if precision is not an integer.

Example

const value = round(1, 1.2345); // 1.2
const value = round(2, 1.2345); // 1.23
const value = round(3, 1.2345); // 1.235
const value = round(3.1, 1.2345); // Error