parrotTrouble

Easy · Basic Logic · 5 test cases

We have a loud talking parrot. The 'hour' parameter is the current hour time in the range 0..23. We are in trouble if the parrot is talking and the hour is before 7 or after 20. Return true if we are in trouble.

Examples

parrotTrouble(true, 6) → true
parrotTrouble(true, 7) → false
parrotTrouble(false, 6) → false

Starter code

function parrotTrouble(talking, hour) {

}

Complexity of the optimal solution

Time O(1), space O(1). The solution involves a single conditional check and basic arithmetic. These operations take a constant amount of time. It uses no extra memory that scales with input size.

Solve parrotTrouble in the browser