What is switch?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • MyrinNew
    Senior Member
    • Feb 2024
    • 5175

    #1

    What is switch?

    • The switch statement is used to check multiple conditions and it runs different code block based on the matching value.
    • If you use more number of if-else-if statements and you use a switch statements.
    • If you use a switch statement the cleaner code, easy to understand.




    let day;
    switch(day)
    {
    case 1:
    console.log("Sunday")
    break;
    case :
    console.log("Monday")
    break;
    case 3:
    console.log("Tuesday")
    break;
    }










    More...
Working...