Command Palette

Search for a command to run...

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

Even or odd?

Finish the function evenOrOdd(n) so it returns the string "even" when the whole number n is even and "odd" when it is odd.

It must work for 0 and for negative numbers too, like -3 and -8.

What Check tests

  1. Even numbers give "even"
  2. Odd numbers give "odd"
  3. 0 is even
  4. Negative numbers work: -3 is odd, -8 is even

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.