Skip to content

Commit 795fb29

Browse files
authored
toFixed
1 parent d9fb768 commit 795fb29

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

README.md

+16-2
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,7 @@
4646
|40 | [pay attention when using every](#pay-attention-when-using-every)|
4747
|41 | [How to convert an array of key-value tuples into an object](#How-to-convert-an-array-of-key-value-tuples-into-an-object)|
4848
|42 | [Native text to speech JS](#Native-text-to-speech-JS)|
49-
50-
49+
|42 | [Native text to speech JS](#Native-text-to-speech-JS)|
5150

5251

5352

@@ -924,4 +923,19 @@ const startSpeaking=()=>{
924923
}
925924
926925
926+
```
927+
928+
**[⬆ Back to Top](#table-of-contents)**
929+
### toFixed()
930+
931+
Warning: Floating point numbers cannot represent all decimals precisely in binary. This can lead to unexpected results, such as 0.1 + 0.2 === 0.3 returning false .
932+
933+
```javascript
934+
935+
123.678.toFixed() // Returns '124'
936+
123.678.toFixed(1) // Returns '123.7': Note rounding
937+
938+
2.35.toFixed(1) // Returns '2.4'. Note it rounds up
939+
2.65.toFixed(1) // Returns '2.6'. Note it rounds down -why??? see the warning above
940+
927941
```

0 commit comments

Comments
 (0)