function caseInSwitch(val) {
var answer = “”;
// Only change code below this line
switch (val) {
case “alpha”:
break;
case “beta”:
break;
case “gamma”:
break;
case “delta”:
break;
default:
// Only change code above this line
return answer;
}
// Change this value to test
caseInSwitch(1);
It’s not passing and I cannot understand how to get the answer. What is the answer? Can someone give me the answer to this problem? Thanks
Oh, sorry, I had to go back and look at the challenge; I had forgotten how it worked! Case 1 should return “alpha”. You will need to change your code in the switch(val) to set the answer to “alpha” if the case is 1, and so on. Hope that helps!
I changed it to this but I still get 3 yellow triangles as errors:
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;
default:
// Only change code above this line
return answer;
}
}
// Change this value to test
caseInSwitch(1);
This is how I did the problem. A few different ways to solve, but this solution helps the answer make more sense I believe. You have to remember the end goal is getting the answer to return something. Have to make sure it is getting stored to answer.
function caseInSwitch(val) {
var answer = “”;
// Only change code below this line
switch(val){
case 1:
answer = “alpha”;
break;
case 2:
answer = “beta”;
break;
case 3:
answer = “gamma”;
break;
case 4:
answer = “delta”;
break;
default:
}
// Only change code above this line
return answer;
}