/ Published in: JavaScript
Very basic switch statement.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
function switchTest(x){ switch(x){ case 1: console.log("x equals 1"); return x; case 2: console.log("x equals 2"); return x; case 3: console.log("x equals 3"); return x; default: console.log("x doesn't equal 1 to 3"); return x; } }