Switch

A switch statement is used to perform different actions based on different conditions.

Code Structure
var day = prompt("Enter the day.");
switch(day) {
 case "Friday":
  alert("TGIF");
  break;
 case "Saturday":
 case "Sunday":
  alert("Weekend");
  break;
 default:
  alert("Weekday");
}

Share this

Related Posts