How to use switch case statement in javascript with Example
3033 Views
Switch case Syntax
switch (case value){
case 1:
break;
case 2:
break;
case 3:
break;
default:
}
Example
var caseValue = 2;
switch (caseValue){
case 1:
document.write("One");
break;
case 2:
document.write("Two");
break;
case 3:
document.write("Three");
break;
default:
document.write("Not 1,2 or 3");
}