Even, odd or zero

Read a whole number and say whether it is zero, even or odd.

What to build

A program with three possible answers, where the order of the tests matters.

Requirements

  • Read one whole number.
  • Print zero if it is 0.
  • Otherwise, print even or odd.

Input

One whole number.

Output

One word: zero, even or odd.

Constraints

The number is from -1000000 to 1000000.

Example

Input:

7

Output:

odd

Why it works

Zero is tested first because it would otherwise count as even. The test for even compares the remainder with 0, because for a negative odd number n % 2 is -1, not 1.

Examples

Example 1 · Input
7
Expected output
odd
Example 2 · Input
10
Expected output
even

Hints

Hint 1

Convert the input first: Number(prompt()).

Hint 2

n % 2 is the remainder after dividing by 2.

Hint 3

For a negative odd number, n % 2 is -1, not 1: test n % 2 === 0 for even.

Solution

Show one correct solution (try it yourself first)
const n = Number(prompt());
if (n === 0) {
  console.log("zero");
} else if (n % 2 === 0) {
  console.log("even");
} else {
  console.log("odd");
}

Lesson: Decisions: if, else and switch →