Use a descriptive camelCase name and show its value.
Acceptance criteria
- 1.#out should show named.
JavaScript Tutorial · JavaScript Statement & Expression
These 10 tasks go with the JavaScript Identifiers chapter. 5 of them ask you to build something small from scratch; 5 give you code that is already broken and ask you to work out why. Set aside about 90 minutes for the whole set, though you can do them in any order.
Nothing here is marked by a person. When you press Submit, the editor checks your code against the points listed under each task and tells you straight away what passed and what didn't (you need a free account to submit). If you get stuck, there are hints, and a worked solution once you've had a go. The first 2 tasks are free; the rest are part of the practice plan.
If it's been a while since you read the chapter, here is how it starts: “JavaScript identifiers are names used to identify variables, functions, objects, classes, and other items in code.” .
1.Name a variable clearlyexercise · easy · 10 min
Use a descriptive camelCase name and show its value.
Passes when: #out should show named.
2.Use an underscore nameexercise · easy · 10 min · practice plan
Underscores are valid in identifiers — prove it.
Passes when: #out should show underscored.
3.Use a dollar sign nameexercise · easy · 10 min · practice plan
A $ is a valid identifier character.
Passes when: #out should show dollared.
4.Use a number inside a nameexercise · easy · 10 min · practice plan
Digits are allowed after the first character.
Passes when: #out should show level2.
5.Keep names consistentexercise · medium · 10 min · practice plan
Declare and read the same identifier exactly.
Passes when: #out should show consistent.
6.Fix the name starting with a digitbug fix · easy · 8 min
An identifier cannot begin with a number.
Passes when: #out should show valid.
7.Fix the hyphen in the namebug fix · easy · 8 min · practice plan
A hyphen is read as subtraction, not part of a name.
Passes when: #out should show hyphenless.
8.Fix the mismatched namebug fix · easy · 8 min · practice plan
The variable is declared one way and read another.
Passes when: #out should show matched.
9.Fix the space in the namebug fix · easy · 8 min · practice plan
Identifiers cannot contain spaces.
Passes when: #out should show spaceless.
10.Fix the reserved word namebug fix · easy · 8 min · practice plan
return cannot be used as a variable name.
Passes when: #out should show renamed.
Between them these tasks cover Valid names and Naming conventions.
Looking for a different chapter? See every practice set, or switch to the interview theory questions.