Puzzle 3 | The Mathemagician |
| const largeNumber = Math.pow(10, 16); |
| const smallNumber = 1; |
| |
| console.log(largeNumber + smallNumber); |
Guess the Output | |
---|---|
Try to guess what the output is before moving to the next page. |
You might have expected the output to be 10000000000000001, but this code will actually log:
| 10000000000000000 |
Discussion
In JavaScript, the Math.pow() function can be used to raise a number to ...
Get JavaScript Brain Teasers now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.