At a contest, children can participate only if they have ages between minAge and maxAge. Given the age of a child, check if they are allowed or not.
Example 1:
Input: minAge = 7, maxAge = 12, age = 7 Output: true
Example 2:
Input: minAge = 3, maxAge = 8, age = 10 Output: false
Hints:
You can solve it in 3 different ways:
1. By checking for invalidations and return
false when age < minAge and when age > maxAge, otherwise return true2. Using one
if statement with 2 conditions and return true, otherwise false3. Since the function return value is a boolean, instead of using an
if, you just return the condition since its value is a boolean.
Free plan: 30 tutor messages. Premium is unlimited.
Saved
Ctrl + Enter to check