Facebook Pixel

Voting Eligibility

JavaScript
easy
5 mins

You are given an integer age representing the age of a person. Your task is to determine whether the person is eligible to vote or not. A person is eligible to vote if their age is 18 years or older. Write a program that checks this condition and returns:

"Eligible to vote" if the age is 18 or above. "Not eligible to vote" if the age is below 18.

Constraints

0 ≤ age ≤ 150

Examples

Example 1:

Input: 20 Output: Eligible to vote
  • Explanation: Since the person’s age is 20, which is greater than 18, they are eligible to vote.

Example 2:

Input: 17 Output: Not eligible to vote Explanation: The age is below 18, so the person cannot vote yet.

Example 3:

Input: 18 Output: Eligible to vote
  • Explanation: The minimum eligible age is 18, so the person can vote.

Companies:

tcs
infosys
wipro

Solve Similar questions 🔥

Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.