Skip to main content
🟨 JavaScript Foundations

Conditionals

if / else let your program make decisions.

if (score > 100) {
  return "high";
} else {
  return "low";
}

The % (modulo) operator gives the remainder of a division. n % 2 is 0 for even numbers.

Your task

Write a function evenOrOdd that returns the string "even" if the number is even, and "odd" otherwise.

⚑ 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
evenOrOdd(4) === "even"
evenOrOdd(7) === "odd"
evenOrOdd(0) === "even"

Run your code to check these.