0% found this document useful (0 votes)
2 views2 pages

JS Tasks Conditional Statements

The document outlines five tasks related to JavaScript conditional statements, including if, if-else, else if, switch, and nested if statements. Each task provides a specific programming challenge, such as checking eligibility for a driver's license, determining if a number is even or odd, assigning grades based on marks, printing the day of the week, and checking if a number is positive and even or odd. Hints are provided for each task to guide the implementation.

Uploaded by

Siva Nagendra
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views2 pages

JS Tasks Conditional Statements

The document outlines five tasks related to JavaScript conditional statements, including if, if-else, else if, switch, and nested if statements. Each task provides a specific programming challenge, such as checking eligibility for a driver's license, determining if a number is even or odd, assigning grades based on marks, printing the day of the week, and checking if a number is positive and even or odd. Hints are provided for each task to guide the implementation.

Uploaded by

Siva Nagendra
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

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]

You might also like