What’s wrong with my code? I checked it against the answer here, and it’s exactly the same. It even returns all the right values in the tests, but it’s giving me errors for having “if” “else” and not enough “break” statements, even though the code doesn’t violate any of these rules. Please help.
Edit: The answers provided on the forum are also flagged with all kinds of issues when copy-pasted, unable to complete this challenge and move on.
function chainToSwitch(val) {
var answer = "";
// Only change code below this line
switch(val) {
case "bob":
answer= "Marley";
break;
case 42:
answer= "The Answer";
break;
case 1:
answer= "There is no #1";
break;
case 99:
answer= "Missed me by this much!";
break;
case 7:
answer "Ate Nine";
break;
}
// Only change code above this line
return answer;
}
// Change this value to test
chainToSwitch(99);
Using Chrome.
Link to the challenge:
https://www.freecodecamp.org/challenges/replacing-if-else-chains-with-switch