Gatekeeper's Vault

EasyAcc. 94.1%
+20 XP 8

Layered Security

The deepest secrets are guarded by multiple gates. To check a user's role, you must first verify they are even allowed through the front door. This is where Nesting comes in—placing a decision inside another decision.

The Assignment

Your function receives isLoggedIn and isAdmin.

  1. Open the first gate with isLoggedIn.
  2. Inside, check their ranking with isAdmin:
    • If isAdmin is true: Greet them with "Welcome, Admin!"
    • Otherwise: Greet them with "Welcome, User!"
  3. If the first gate even fails to open (else of the outer block): Tell them "Please log in."

01EXAMPLE 1

InputisLoggedIn = true, isAdmin = false
OutputLogs: "Welcome, User!"

Explanation: User is logged in but not an admin.

02EXAMPLE 2

InputisLoggedIn = false, isAdmin = true
OutputLogs: "Please log in."

Explanation: Outer check fails, so inner check never runs.

Constraints

  • Use nested if statements.
  • Messages must match exactly including punctuation.
Control FlowConditionalsFundamentals
JavaScript
Loading...
4 Hidden

Input Arguments

isLoggedIntrue
isAdminfalse

Expected Output

Welcome, User!

Click RUN to test your solution