PROBLEM 40
Easy

Positive, Negative, or Zero

Programming Basics · JavaScript

</>
STATUS Not solved

TASK

Problem

#40

Given integer `n`, print `POSITIVE`, `NEGATIVE`, or `ZERO`.

EXAMPLE

Example

Input
0
Output
ZERO

LIMITS

Constraints

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

### Positive, Negative, or Zero

`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.', 'Match each input value type to the operation performed on it: JavaScript string and numeric behavior differ significantly.']

ANSWER Solution
+
const fs = require('fs');
const input = fs.readFileSync(0, 'utf8').trimEnd();
let n = Number(input);
if (n > 0) {
    console.log("POSITIVE");
} else {
    if (n < 0) {
        console.log("NEGATIVE");
    } else {
        console.log("ZERO");
    }
}