DEV Community

Arul .A
Arul .A

Posted on

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;
}

Enter fullscreen mode Exit fullscreen mode

Top comments (0)