let fruit = "Apple";
let message;
switch (fruit) {
case "Banana":
message = "Bananas are yellow.";
break;
case "Apple":
message = "Apples are red or green.";
break;
case "Orange":
message = "Oranges are orange, obviously!";
break;
default:
message = "I don't know that fruit.";
}
console.log(message);
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter