Even or Odd? π¬
If you can split your candy into two equal piles, the number is even. If one piece is left over, it's odd.
The secret tool is % (say "remainder"). It tells you what's left over after
sharing:
6 % 2 // 0 β nothing left over β even!
7 % 2 // 1 β one left over β odd
So n % 2 === 0 is true when the number is even.
Your task
Write isEven(n) that hands back true when n is even, and false when it's
odd.
β‘ 25 XP
π§± Code blocks
Drag a block into the editor, or tap it to drop it in where your cursor is. Add them in order to build your answer.
solution.jsRuns in your browser
Loading editorβ¦
Tests3 to pass
4 is even
7 is odd
0 is even
Run your code to check these.