Update article.md
This commit is contained in:
parent
291b5c05b9
commit
ee1daf7664
1 changed files with 1 additions and 1 deletions
|
@ -246,7 +246,7 @@ Can we work around the problem? Sure, the most reliable method is to round the r
|
|||
|
||||
```js run
|
||||
let sum = 0.1 + 0.2;
|
||||
alert( sum.toFixed(2) ); // 0.30
|
||||
alert( sum.toFixed(2) ); // "0.30"
|
||||
```
|
||||
|
||||
Please note that `toFixed` always returns a string. It ensures that it has 2 digits after the decimal point. That's actually convenient if we have an e-shopping and need to show `$0.30`. For other cases, we can use the unary plus to coerce it into a number:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue