Practice
JavaScriptData StructuresReactConcepts
Sign in
← Back to problems

Even or Odd (Remainder)

Numbers, Dates & Timerseasy

Course · Section 12: Numbers, Dates, Intl and Timers · Lecture 183: The Remainder Operator

Implement `evenOdd(n)` returning the string `even` or `odd` using the remainder operator.

Sample tests

Input: evenOdd(4)
Output: "even"
Input: evenOdd(7)
Output: "odd"

+ 1 hidden test run on Submit.

Hints

Common pitfalls
  • Negative odds still have a non-zero remainder.
Approach & explanation (try first)

The remainder operator tells you divisibility by two.

Loading...
⌘/Ctrl + Enter

Run your code to see results.