Adult Check
Programming Basics · JavaScript
TASK
Problem
Given age, print `YES` if it is at least 18, otherwise `NO`.
EXAMPLE
Example
18
YES
LIMITS
Constraints
0 ≤ age ≤ 120
LEARN
Theory for this problem
+
### Adult Check
`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 age = Number(input);
if (age >= 18) {
console.log("YES");
} else {
console.log("NO");
}