Round to Decimals

Round a floating-point number to a specified number of decimal places for precision control.

Code

General
Number(num.toFixed(decimals));

Parameters

The number to round

Number of decimal places

Browser·fetch() may be limited by CORS

More JavaScript Snippets