Access to Restricted Area

Let's define the function canAccessRestrictedArea:

function canAccessRestrictedArea(age, hasClearanceBadge) {
    // Function body will go here
}

Inside the function, we need to check if either of the conditions is true:

  • age >= 18: Checks if the person is at least 18 years old.

  • hasClearanceBadge: Checks if the person has the special clearance badge.

We return true if either condition is true (indicating the person can access the restricted area), otherwise we return false.

function canAccessRestrictedArea(age, hasClearanceBadge) {
    // Check if the person meets the conditions to access the restricted area
    if (age >= 18 || hasClearanceBadge) {
        return true;  // Return true if either condition is true
    }

    return false; // Otherwise, return false
}