I think that when you use return in a switch statement you should call the function with console.log. In this lesson, the pre-written statements use return in the switch statements and just call the function without console.log. I ran the solution through vscode and found that it won’t output any words unless you put console.log when you call the function out or put console.log instead of return in the switch statements. I believe the pre-written return statement should be surrounded by a console.log just to make sense.
Your code so far
function caseInSwitch(val) {
var answer = "";
// Only change code below this line
switch(val) {
case 1:
return "alpha";
break;
case 2:
return "beta";
break;
case 3:
return"gamma";
break;
case 4:
return "delta";
}
// Only change code above this line
return answer;
}
caseInSwitch(1);
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.97 Safari/537.36.
Challenge: Selecting from Many Options with Switch Statements
Link to the challenge: