The "switch" statement

The "switch" statement

A switch statement could be used instead of many if conditions.

On the following example x is the value to be compared and case values are when x equals to that.
Using break will quit the switch statement. If it does not meet any conditions then it will be hitting default statement.

switch(x) {
case 'Approved': // if (x === 'value1')
alert("It has been already approved");
break;
case 'Pending': // if (x === 'value2')
alert("Please approve the item");
break;
default:
alert("This has not been submitted yet");
break;
}