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.
- Open the first gate with
isLoggedIn. - Inside, check their ranking with
isAdmin:- If
isAdminis true: Greet them with "Welcome, Admin!" - Otherwise: Greet them with "Welcome, User!"
- If
- If the first gate even fails to open (
elseof the outer block): Tell them "Please log in."
01EXAMPLE 1
Input
isLoggedIn = true, isAdmin = falseOutput
Logs: "Welcome, User!"Explanation: User is logged in but not an admin.
02EXAMPLE 2
Input
isLoggedIn = false, isAdmin = trueOutput
Logs: "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
JavaScriptSystem handles I/O — write your function only
Loading...
4 Hidden
Input Arguments
isLoggedIntrue
isAdminfalse
Expected Output
Welcome, User!
Click RUN to test your solution