Round a number to n digits of precision after the decimal point.
Time complexity: O(1)
Space complexity: O(1)
Value to format
Number of digits of precision after the decimal point
Number rounded to the specified number of digits
const value = 12.345;toDigits(value, 2); // 12.35 Copy
const value = 12.345;toDigits(value, 2); // 12.35
Round a number to n digits of precision after the decimal point.
Time complexity: O(1)
Space complexity: O(1)