Javascript — Switch Statement
switch
lets you run different blocks of code based on a variable's value. It's cleaner than many if-else
conditions.
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\");
}