Pattern: Missing digits argument in Number#toFixed()
Issue: -
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.
Example of incorrect code:
number.toFixed();
Example of correct code:
number.toFixed(0);
number.toFixed(2);