Javascript - switch statements
Code Life
By Pierre Marsaa
The switch Statement
When you compare the same variable against many exact values, an else if chain gets repetitive. JavaScript has a cleaner tool for that: switch.
↗️
Loading editor...
↶
↷
switch takes the value of codemonType and looks for the case that matches it exactly. Here it finds case "water" and runs its code. Try changing the type!
Verify