9 JavaScript Conditional Statements
Tasks
✅ 1. if Statement
Question:
Write a program to check whether a person is eligible for Driver License or not. (Eligibility
age is 18)
🧠 Hint: Use an if condition to check if age is greater than or equal to 18.
✅ 2. if-else Statement
Question:
Write a program to check whether a given number is even or odd.
🧠 Hint: Use number % 2 === 0 to check even numbers. A Number is even if it is divisible by
2 otherwise false.
✅ 3. else if Statement
Question:
Write a program to assign a grade based on marks:
● 90 and above → A
● 75 to 89 → B
● 50 to 74 → C
● Below 50 → F
🧠 Hint: Use multiple else if conditions to check ranges.
✅ 4. switch Statement
Question:
Write a program that prints the day of the week when a number (1-7) is given:
● 1 → Monday
● 2 → Tuesday
● …
● 7 → Sunday
🧠 Hint: Use a switch statement with case for each number.
✅ 5. Nested if Statement
Question:
Write a program to check if a number is positive, and if it is, then also check whether it is
even or odd.
🧠 Hint: First use if (num > 0), then inside it use another if-else for even/odd.
Our YouTube Channel -
[Link]