The Cryptic Threshold
EasyAcc. 92.7%
+20 XP 8
Multi-Layered Guardians
Sometimes a simple "Yes or No" isn't enough. You might need to check a second condition ONLY IF the first one fails. This creates a logical fallback system where different rules apply to different groups.
The Assignment
Your function receives inputAge and hasParentConsent.
- Create an outer
if-elseto check theinputAge:- If
inputAgeis 18 or greater, print: "Adult access granted."
- If
- In the outer else block (if they are under 18), check their
hasParentConsent:- If they have consent, print: "Minor access with parental consent."
- Otherwise, print: "Minor access denied."
01EXAMPLE 1
Input
inputAge = 25, hasParentConsent = falseOutput
Logs: "Adult access granted."Explanation: Adults pass the first gate.
02EXAMPLE 2
Input
inputAge = 15, hasParentConsent = falseOutput
Logs: "Minor access denied."Explanation: Minor without consent is turned away.
Constraints
- Use nested if-else statements.
- Log messages must match exactly.
Control FlowConditionalsFundamentals
JavaScriptSystem handles I/O — write your function only
Loading...
3 Hidden
Input Arguments
inputAge25
hasParentConsentfalse
Expected Output
Adult access granted.
Click RUN to test your solution