Tell us what’s happening:
Hey everyone! I’ve coded this far and don’t know why it returns “delta” instead of “alpha” ! I’ve read about switch on MDN, and it didn’t explain, why it will return the results that don’t match the criteria, in this case “val” as the argument of the function, whenever “break” keyword is omitted.
It’ll be so kind of you, if you help me with this. Thanks a lot!
Your code so far
function caseInSwitch(val) {
let answer = "";
// Only change code below this line
switch (val) {
case 1 :
answer = "alpha";
case 2:
answer = "beta";
case 3:
answer = "gamma";
case 4:
answer = "delta";
}
// Only change code above this line
return answer;
}
caseInSwitch(1);
Your browser information:
Challenge: Basic JavaScript - Selecting from Many Options with Switch Statements
Link to the challenge: