JavaScript If-Condition Programs for Practice

Beginner Level

  1. Check whether a number is positive.
  2. Check whether a number is negative.
  3. Check whether a number is zero.
  4. Check whether a number is even.
  5. Check whether a number is odd.
  6. Check whether a person is eligible to vote (age >= 18).
  7. Check whether a student has passed (marks >= 35).
  8. Check whether a number is divisible by 5.
  9. Check whether a number is divisible by 10.
  10. Check whether a character is an uppercase letter.
  11. Check whether a character is a lowercase letter.
  12. Check whether a character is a vowel.
  13. Check whether a character is a consonant.
  14. Check whether a number is greater than 100.
  15. Check whether a person is eligible for a driving license (age >= 18).

Intermediate Level

  1. Check whether a number is divisible by both 3 and 5.
  2. Find the greater of two numbers.
  3. Find the smaller of two numbers.
  4. Check whether two numbers are equal.
  5. Check whether three numbers are all equal.
  6. Find the largest of three numbers.
  7. Find the smallest of three numbers.
  8. Check whether a year is a leap year.
  9. Check whether a number is a multiple of 7.
  10. Check whether a salary is greater than ₹50,000.
  11. Check whether a password length is at least 8 characters.
  12. Check whether a person is a teenager (age between 13 and 19).
  13. Check whether a number is within the range of 1 to 100.
  14. Check whether a product price is eligible for free shipping (price >= ₹500).
  15. Check whether a temperature is below the freezing point.

Advanced Beginner Level

  1. Assign a grade based on marks.
  2. Check whether a number is a three-digit number.
  3. Check whether a number is a four-digit number.
  4. Check whether a number is positive and even.
  5. Check whether a person can enter a movie (age >= 18 and has a ticket).
  6. Check whether a username is "admin".
  7. Check whether a user is logged in.
  8. Check whether an email contains "@".
  9. Check whether a mobile number has exactly 10 digits.
  10. Check whether a number is divisible by either 2 or 3.

Real-World Practice

  1. Check whether an account balance is sufficient for withdrawal.
  2. Check whether an OTP entered is correct.
  3. Check whether a coupon code is valid.
  4. Check whether a shopping cart has items.
  5. Check whether a student has attendance greater than or equal to 75%.
  6. Check whether a user is eligible for a senior citizen discount (age >= 60).
  7. Check whether a customer gets a discount (purchase amount > ₹2000).
  8. Check whether the current time is AM or PM.
  9. Check whether a file size exceeds 5 MB.
  10. Check whether a string is empty.

Challenge Exercises

  • Check whether a number is divisible by 2, 3, and 5.
  • Check whether a person is eligible for a loan (age and salary conditions).
  • Check whether a password is strong (length, uppercase, lowercase, number, special character).
  • Check whether a student passed all subjects.
  • Check whether a user can access an admin panel based on role.
  • Check whether a number lies between two given numbers.
  • Check whether today’s day is a weekend.
  • Check whether an item is in stock before placing an order.
  • Check whether a vehicle is eligible for pollution certification based on its age.
  • Check whether a customer qualifies for free delivery based on location and order amount.

Leave a Comment