JavaScript Identifiers — exercises and bug fixes
5 hands-on exercises and 5 find-the-bug challenges for the JavaScript Identifiers 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
Name a variable clearly
easy10 minUse a descriptive camelCase name and show its value.
- 2
Use an underscore name
easy10 minUnderscores are valid in identifiers — prove it.
- 3
Use a dollar sign name
easy10 minA $ is a valid identifier character.
- 4
Use a number inside a name
easy10 minDigits are allowed after the first character.
- 5
Keep names consistent
medium10 minDeclare and read the same identifier exactly.
Find the bug(5)
- 1
Fix the name starting with a digit
easy8 minAn identifier cannot begin with a number.
- 2
Fix the hyphen in the name
easy8 minA hyphen is read as subtraction, not part of a name.
- 3
Fix the mismatched name
easy8 minThe variable is declared one way and read another.
- 4
Fix the space in the name
easy8 minIdentifiers cannot contain spaces.
- 5
Fix the reserved word name
easy8 minreturn cannot be used as a variable name.
Ready to write the code?
The editor, the automatic checks and the worked solutions open up with an account.
Open the workspace