475.Check Voting Eligibility by Age
Easy
Given a person's
age, return whether they're eligible to vote, assuming the minimum voting age is 18 (inclusive).
A single comparison decides the whole outcome. The if-elseIf-ElseTwo branches, one condition — exactly one of "true" or "false" is returned. version spells out both outcomes explicitly, which is the natural way to write this before the next pattern clicks: once the condition itself already IS the true/false answer you want, returning it directly skips the if-else entirely.
Example 1:
Input: age = 15
Output: false
Example 2:
Input: age = 20
Output: true
Example 3:
Input: age = 18
Output: true
+ 4 hidden test cases run on Submit.
Constraints:
- ●
0 ≤ age ≤ 150
age =
15