User Registration
Programming Basics · JavaScript
TASK
Problem
Given `age` and password length `length`, registration is allowed for age ≥13 and length ≥8. Print `OK` or `REJECTED`.
EXAMPLE
Example
15 10
OK
LIMITS
Constraints
0 ≤ age ≤ 120; 0 ≤ length ≤ 100
LEARN
Theory for this problem
+
### User Registration
JavaScript arithmetic works with numeric values stored in variables. A clear solution reads the needed values, computes the formula with `+`, `-`, `*`, `/` or `**`, and prints only the final result.
NEED HELP?
Hints
+
['Write the formula using named intermediate values if it contains more than one operation.', 'First decide whether the task operates on characters, words, or the whole string; that determines the correct way to split the data.']
ANSWER
Solution
+
const fs = require('fs');
const input = fs.readFileSync(0, 'utf8').trimEnd();
let [a, l] = input.trim().split(/\s+/).filter(Boolean).map(Number);
if ((a >= 13) && (l >= 8)) {
console.log("OK");
} else {
console.log("REJECTED");
}