Skip to content

Files

Latest commit

 

History

History
20 lines (14 loc) · 469 Bytes

require-number-to-fixed-digits-argument.md

File metadata and controls

20 lines (14 loc) · 469 Bytes

Pattern: Missing digits argument in Number#toFixed()

Issue: -

Description

When using Number#toFixed(), explicitly specifying the number of decimal places makes the code's intent clearer rather than relying on the default value of 0. This helps prevent confusion and improves code readability.

Examples

Example of incorrect code:

number.toFixed();

Example of correct code:

number.toFixed(0);
number.toFixed(2);