JavaScript Keywords — exercises and bug fixes
5 hands-on exercises and 5 find-the-bug challenges for the JavaScript Keywords lesson. Every one is checked automatically in the browser — write the code, run it, and the tests tell you what still fails.
Exercises(5)
- 1
Use the const keyword
easy10 minDeclare a constant and display it.
- 2
Use the typeof keyword
easy10 minReport the type of true.
- 3
Use the return keyword
easy10 minReturn a value from a function and show it.
- 4
Use the new keyword
easy10 minCreate a Date and confirm it worked.
- 5
Use the this keyword
medium10 minRead a property through this inside a method.
Find the bug(5)
- 1
Fix the reserved word used as a name
easy8 minclass is a reserved keyword and cannot be a variable name.
- 2
Fix the missing return
easy8 minThe function computes a value but never returns it.
- 3
Fix the missing new keyword
easy8 minDate without new returns a string, not a Date object.
- 4
Fix the wrong typeof target
easy8 minThis reports the type of a string, not a boolean.
- 5
Fix this inside an arrow function
easy8 minAn arrow method has no own this, so the lookup fails.
Ready to write the code?
The editor, the automatic checks and the worked solutions open up with an account.
Open the workspace