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.

  1. Check if the user has the key.
  2. If they do, check if the password is exactly "Secret".
  3. If both are true, return "Access Granted". Otherwise, return "Denied".

01EXAMPLE 1

InputhasKey=true, password='Secret'
Output"Access Granted"

Constraints

    FundamentalsLogic
    JavaScript
    Loading...
    3 Hidden

    Input Arguments

    hasKeytrue
    password"Secret"

    Expected Output

    Access Granted

    Click RUN to test your solution