PROBLEM 58
Medium

Age Category

Programming Basics · JavaScript

</>
STATUS Not solved

TASK

Problem

#58

Print `CHILD` for 0–12, `TEEN` for 13–17, `ADULT` for 18–64, and `SENIOR` for 65+.

EXAMPLE

Example

Input
17
Output
TEEN

LIMITS

Constraints

0 ≤ age ≤ 120
📖
LEARN Theory for this problem
+

### Age Category

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.', '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 a = Number(input);
if (a <= 12) {
    console.log("CHILD");
} else {
    if (a <= 17) {
        console.log("TEEN");
    } else {
        if (a <= 64) {
            console.log("ADULT");
        } else {
            console.log("SENIOR");
        }
    }
}