📲 Download Our Apps

EMI Calculator

Download EMI Calculator

SOA Games

Download SOA Games

SOA Technology App

Download SOA Technology

BMI Checker

Download BMI Checker

Task Jira

Download Task Jira

Laughing Adda

Download Laughing Adda

📅 हिंदी कैलेंडर ऐप डाउनलोड करें

Download Shubhcalendar App

30 JavaScript interview/practice questions focused on if, else if, and else statements, from basic to a bit tricky

🟢 Basic Level (1–10)

  1. What is an if statement in JavaScript?
  2. Write a program to check if a number is positive.
  3. How do you check if a number is even or odd using if?
  4. What is the syntax of if...else in JavaScript?
  5. Write a program to check if a person is eligible to vote.
  6. What happens if the condition inside if is false?
  7. Can we use multiple if statements without else?
  8. Write a program to check whether a number is greater than 100.
  9. How do comparison operators work in an if condition?
  10. What is the difference between == and === in an if statement?

🟡 Intermediate Level (11–20)

  1. Write a program to find the largest of two numbers using if.
  2. Write a program to find the largest of three numbers using if...else if.
  3. How do logical operators (&&, ||, !) work inside if conditions?
  4. Write a program to check whether a year is a leap year.
  5. What is nested if? Give an example.
  6. How does JavaScript treat non-boolean values in if conditions?
  7. What are truthy and falsy values? Name at least 5 falsy values.
  8. Write a program to check if a character is a vowel.
  9. What is the difference between if...else if and switch?
  10. Write a program to check whether a user is an adult and has a driving license.

🔴 Advanced / Tricky (21–30)

  1. What will be the output?
if ("0") {
  console.log("True");
} else {
  console.log("False");
}
  1. What will be the output?
if (0 == false) {
  console.log("Equal");
}
  1. What will be the output?
if (null) {
  console.log("Yes");
} else {
  console.log("No");
}
  1. What will be the output?
if (undefined == null) {
  console.log("Same");
}
  1. Can an if statement exist without curly braces {}? Explain.
  2. What is short-circuit evaluation in if conditions?
  3. How can you replace a simple if...else with a ternary operator?
  4. Write a program that checks multiple conditions in a single if statement.
  5. What is the scope of variables declared inside an if block?
  6. What are common mistakes developers make while using if statements in JavaScript?



Leave a Reply

AI Spiritual Tools & Interactive Experiences

Explore powerful AI-driven tools for daily guidance, spirituality, fun quizzes, and self-discovery.

Today’s Quote

Get inspiring daily quotes powered by AI to motivate and guide your day.

Explore Now

AI Tarot Card Reader

Reveal insights about your future, love, and career with AI tarot readings.

Read Tarot

Love Match Calculator

Check compatibility and love predictions using AI-based analysis.

Check Match

Fortune Cookie

Open an AI fortune cookie and receive wisdom, luck, and fun messages.

Open Cookie

Quiz Categories

Engage with knowledge-based and fun quizzes across multiple categories.

Start Quiz

Panchang Calendar

View daily Panchang, auspicious timings, tithi, nakshatra, and festivals.

View Panchang

Online Numerology

Discover your destiny number, life path, and numerology predictions.

Calculate Now

Spiritual Feeds

Stay connected with spiritual thoughts, mantras, and divine content.

View Feeds

Quiz Hub

Attempt trending quizzes on GK, spirituality, festivals, and more.

Explore Quizzes