The switch statement compares the value of an expression against a set of predefined conditions also
referred to as cases if there is a match.
The block of code associated with that case is executed.
In this example we have a variable with the value Volvo assigned to it next.
We created a switch statement pertaining to the car variable with four cases
in the case at the car.
Variable is equal to Volvo will output the text you drive a Volvo in the second case if the variable
value is BMW will output the text you drive a BMW and in the third case if the car variables value is
Honda will output the text.
You drive a Honda.
We don't use the default statement to output the text.
You don't drive if the car variable does not equal any of the cases defined above so as you can see
it's relatively straightforward since our car variable is set to Volvo in our web browser.
We can expect the statement you drive a Volvo to be good.
If we change this to BMW
you can see that the state now changes too.
You drive a BMW.
Now what if we put something completely unrelated will change the car variable to the value Merc.
You can see that since Merck is in none of the cases it results of the default which is the statement
you don't drive.