The switch statement above is the same as the if statement above, but it's a lot cleaner to look at. Each case is equivalent to an if or else if branch and the break keyword tells JavaScript to stop execution after a case has been met. If you don't have the break for each case then you have what is called a cascading switch statement meaning the cases will execute until a break is encountered. Similarly the default label tells the switch statement to execute the default case if none of the other cases are met.

Both codes will produce the same output:

The syntax for a switch statement is

switch(expression) {
case statements
}

The matching case of the switch expression uses the === equality not the == equality. Meaning the expression must match without any type conversion.