freeCodeCamp Challenge Guide: Selecting from Many Options with Switch Statements

Hello,
I am agree, this section lacks of explanations. Here is my code :

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”;
break;
}
// Only change code above this line
return answer;
}

// Change this value to test
caseInSwitch(1);

It passes the test but I still have the following error :

Unreachable ‘break’ after ‘return’

13 Likes