PROBLEM 31
Easy

Even or Odd

Programming Basics · JavaScript

</>
STATUS Not solved

TASK

Problem

#31

Given integer `n`, print `EVEN` if it is even, otherwise `ODD`.

EXAMPLE

Example

Input
17
Output
ODD

LIMITS

Constraints

All numeric input values fit in JavaScript `Number`.
📖
LEARN Theory for this problem
+

### Even or Odd

`if / else if / else` chooses a branch from boolean conditions. Comparisons such as `<`, `>=`, `===` and logical operators `&&`, `||`, `!` combine the exact rules that decide which output is valid.

💡
NEED HELP? Hints
+

['Translate every case from the statement into a boolean condition before writing branches.', 'Order the checks so a more specific case is not swallowed by a broader condition.']

ANSWER Solution
+
const fs = require('fs');

const n = Number(fs.readFileSync(0, 'utf8').trim());
const result = n % 2 === 0 ? 'EVEN' : 'ODD';

console.log(result);