switch with condition javascript code example
Example 1: js switch case
switch(expression) {
case x:
break;
case y:
break;
default:
}
Example 2: javascript switch
let color = "black";
switch(color){
case "red":
console.log("color is red");
break;
case "white":
console.log("color is white");
break;
case "black":
console.log("color is black");
break;
default:
console.log("unknow color");
}
Example 3: switch statement js
switch (expression) {
case value1:
[break;]
case value2:
[break;]
...
case valueN:
[break;]
[default:
[break;]]
}