Show "A" for 90+, "B" for 80+, otherwise "C". The score is 85.
Acceptance criteria
- 1.#out should show B.
JavaScript Tutorial · JavaScript Conditions
These 10 tasks go with the JavaScript else if Statement 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: “The JavaScript else if statement is used when you need to check multiple conditions.” .
1.Grade a scoreexercise · easy · 10 min
Show "A" for 90+, "B" for 80+, otherwise "C". The score is 85.
Passes when: #out should show B.
2.Describe a temperatureexercise · easy · 10 min · practice plan
Show "hot" above 30, "warm" above 20, otherwise "cold". It is 25.
Passes when: #out should show warm.
3.Map a role to accessexercise · easy · 10 min · practice plan
admin sees "full", editor sees "partial", anyone else "none". The role is editor.
Passes when: #out should show partial.
4.Classify a numberexercise · easy · 10 min · practice plan
Show "negative", "zero" or "positive" for the value 0.
Passes when: #out should show zero.
5.Pick a shipping bandexercise · medium · 10 min · practice plan
Free over 100, "standard" over 50, else "express". The total is 60.
Passes when: #out should show standard.
6.Fix the branch orderbug fix · easy · 8 min
The widest test comes first, so it swallows every score.
Passes when: #out should show A.
7.Fix the separate ifsbug fix · easy · 8 min · practice plan
Two independent ifs both run, so the last one wins.
Passes when: #out should show warm.
8.Fix the missing elsebug fix · easy · 8 min · practice plan
An unmatched value leaves the output untouched.
Passes when: #out should show none.
9.Fix the zero testbug fix · easy · 8 min · practice plan
Zero falls into the negative branch because the comparison includes it.
Passes when: #out should show zero.
10.Fix the unreachable branchbug fix · easy · 8 min · practice plan
The final band can never be reached as written.
Passes when: #out should show express.
Between them these tasks cover Chained conditions and Ordering branches.
Looking for a different chapter? See every practice set, or switch to the interview theory questions.