Control Flow: Switch
Dipping Your Toe into Switch statements

In the editor you see a simple switch statement. A switch statement comes in handy when you have a series of if/elseif/else statements with multiple expressions that depend on the same value. The switch statement also provides a bit of efficiency and readability. Switches work like if statements, if a condition is true, it executes a block of code.


Try and figure out which of these case blocks gets executed and smash that Submit button!

View Preview