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.

  1. Create an outer if-else to check the inputAge:
    • If inputAge is 18 or greater, print: "Adult access granted."
  2. 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

InputinputAge = 25, hasParentConsent = false
OutputLogs: "Adult access granted."

Explanation: Adults pass the first gate.

02EXAMPLE 2

InputinputAge = 15, hasParentConsent = false
OutputLogs: "Minor access denied."

Explanation: Minor without consent is turned away.

Constraints

  • Use nested if-else statements.
  • Log messages must match exactly.
Control FlowConditionalsFundamentals
JavaScript
Loading...
3 Hidden

Input Arguments

inputAge25
hasParentConsentfalse

Expected Output

Adult access granted.

Click RUN to test your solution