Puzzle 1 | Your Code Deserves a Lift |
| let temp = 25; |
| |
| function displayTemperature() { |
| console.log(`Current temperature: ${temp} °C`); |
| } |
| |
| function forecastTemperature() { |
| console.log(`Expected temperature: ${temp} °C`); |
| var temp = 28; |
| } |
| |
| displayTemperature(); |
| forecastTemperature(); |
Guess the Output | |
---|---|
Try to guess what the output is before moving to the next page. |
You might have expected the output to be:
| Current temperature: 25 °C |
| Expected temperature: 25 °C |
But this ...
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.