Are Numbers Equal?
Programming Basics · JavaScript
TASK
Problem
Given two integers, print `EQUAL` if they are equal, otherwise `NOT EQUAL`.
EXAMPLE
Example
7 7
EQUAL
LIMITS
Constraints
The input sequence contains at most 100000 elements; numeric values fit in JavaScript `Number`.
LEARN
Theory for this problem
+
### Are Numbers Equal?
`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.', 'Check values exactly on the condition boundary: `=`, `<`, and `>` must match the statement without an off-by-one shift.']
ANSWER
Solution
+
const fs = require('fs');
const input = fs.readFileSync(0, 'utf8').trimEnd();
let [a, b] = input.trim().split(/\s+/).filter(Boolean).map(Number);
if ((a) === (b)) {
console.log("EQUAL");
} else {
console.log("NOT EQUAL");
}