The Double Lock
Medium+20 XP
Mission Briefing
The Inner Sanctum has a double-lock mechanism. A physical key won't work without the vocal password, and the password won't work without the key.
The Concept: Nested Decisions
Sometimes a decision entirely depends on the outcome of a previous decision. You can nest an if statement safely inside another if statement, or combine them using logical operators like &&.
The Objective
Your function receives a boolean hasKey and a string password.
- Check if the user has the key.
- If they do, check if the password is exactly "Secret".
- If both are true, return "Access Granted". Otherwise, return "Denied".
01EXAMPLE 1
Input
hasKey=true, password='Secret'Output
"Access Granted"Constraints
FundamentalsLogic
JavaScriptSystem handles I/O — write your function only
Loading...
3 Hidden
Input Arguments
hasKeytrue
password"Secret"
Expected Output
Access Granted
Click RUN to test your solution