Command Palette

Search for a command to run...

Hectal
Phase 2: Operators and Control Flow
JavaScript · Exercise 2 of 5 PreviousNext
Beginner

Grade calculator

Finish grade(score). It returns "A" for 90 to 100, "B" for 75 up to (not including) 90, "C" for 50 up to 75, and "F" for 0 up to 50.

Scores below 0, above 100, or not a number at all (NaN) must return "invalid".

The button is already wired up: type a score and press Grade it to see the result on the page.

What Check tests

  1. 90 to 100 is an A
  2. 75 up to 90 is a B (89.9 is still a B)
  3. 50 up to 75 is a C, below 50 is an F
  4. Out-of-range scores and NaN are "invalid"
  5. The button shows the grade on the page

Stuck? One hint at a time

The solution unlocks after your first Check. Try first: that is where the learning happens.

Runs in your browser. Your code is saved here.

Your page

Press Run to see the page.

Console

Nothing logged yet.