toFixed()
Returns text with a specified decimal place.
Syntax
number.toFixed(digits)
Description
Rounds the number to the given decimal places and returns it as TEXT (ideal for money display).
Returns
Formatted text (string).
Example
Loading editor…
Expected output
3.14 5.00
When to use?
Price/money display (always 2 decimal places).
Common mistakes
- ⚠️ The result is TEXT; convert it back with Number() if you are going to use it in calculations again.