Learning LabConditions

πŸ”€ Training β€” Conditions

📚 50 questions⏱ 15-20 min🏆 Instant feedback

πŸ”€ Conditional Statements (Conditional Statements) JavaScript

using if, else, switch Ali

🎯 What You Will Learn in This Training

This interactive training will help you master Conditional Statements JavaScript No :

  • βœ… Ali type input string No
  • βœ… statement if execution code Check condition
  • βœ… if...else execution code
  • βœ… using if...else if...else
  • βœ… operator (Nested if)
  • βœ… switch constant
  • βœ… writing using operator No (Ternary Operator)
  • βœ… comparison Nested if operator &&

❓ Conditional Statements (Conditional Statements)?

Conditional Statements code condition (true) (false).

code No No only ✨

let age = 20;
if (age >= 18) {
  console.log("You are allowed to enter βœ…");
}

πŸ”€ 1️⃣ statement if

code execution only Check condition .

let temperature = 30;
if (temperature >25) {
  console.log(" πŸ₯΅");
}

πŸ”„ 2️⃣ statement if...else

code Check condition, Check.

let age = 15;
if (age >= 18) {
  console.log("You are an adult πŸ‘Œ");
} else {
  console.log("You are still a minor 🚸");
}

πŸ“Š 3️⃣ statement if...else if...else

.

let score = 85;
if (score >= 90) {
  console.log("Excellent πŸ₯‡");
} else if (score >= 75) {
  console.log("Good πŸ‘");
} else {
  console.log("Keep trying πŸ’ͺ");
}

🧩 4️⃣ (Nested if)

statement if if Check .

let age = 16;
let country = "USA";
let text = "You can Not drive!";

if (country == "USA") {
  if (age >= 16) {
    text = "You can drive!";
  }
}

console.log(text);

βš–οΈ 5️⃣ Nested if vs Logical AND (&&)

Nested if operator && code.

// Nested if
if (age >= 18) {
  if (hasLicense) {
    message = "You can drive.";
  }
}

// using && ( )
if (age >= 18 && hasLicense) {
  message = "You can drive.";
}

πŸŽ›οΈ 6️⃣ statement switch

constant Check , No using if...else.

let day = "Monday";

switch (day) {
  case"Monday":
    console.log("Start of the week πŸ’Ό");
    break;
  case"Friday":
    console.log("Weekend is near πŸŽ‰");
    break;
  default:
    console.log("Just another day 😎");
}

❓ 7️⃣ operator No (Ternary Operator)

writing condition if...else.

let age = 20;
let message = (age >= 18) ? "Adult πŸ‘Œ" : "Minor 🚸";
console.log(message);

🎯 Choose Training Mode