function caseInSwitch(val) {
let 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;
}
caseInSwitch(1);
I don’t think it should pass, I checked the solutions and it doesn’t match and it doesn’t make much sense that it passed either. Please let me know in either case as it will help me better understand what’s happening. Thank you!
Well, the instructions do say “and sets answer for the following conditions”, so I think the spirit of the challenge is to use the answer variable instead of returning the answer directly from the switch.
That’s what I’m noticing and if it passes like this then it doesn’t really show the learner (me) that I had done it incorrectly to what was being asked. Am I wrong, honestly its still a little confusing for me.
I would tend to agree, why should we care. So maybe the code shouldn’t be seeded with the answer variable to begin with? And of course change the instructions to get rid of a reference to it.
Also, the tests are requiring three breaks, so we would want to remove that requirement as well because you don’t need them if you are returning on each case.
I was just confused when it passed so I looked at the solutions and noticed mine wasn’t aligned. So it further confused me which led me to posting here. I thought maybe there is something I’m missing.