Won't let me pass in spite of working code

It keeps telling me I’m not meeting the following guidelines:
caseInSwitch(1) should have a value of “alpha”
caseInSwitch(2) should have a value of “beta”
caseInSwitch(3) should have a value of “gamma”
caseInSwitch(4) should have a value of “delta”
…but I am!

Why won’t it let me pass the challenge?

My code so far


function caseInSwitch(val) {
var answer = "";
// Only change code below this line
switch(val) {
case 1:
console.log("alpha");
break;
case 2:
console.log("beta");
break;
case 3:
console.log("gamma");
break;
case 4:
console.log("delta");
break;
}
// Only change code above this line
return answer;
}

caseInSwitch(1);

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.80 Safari/537.36.

Challenge: Selecting from Many Options with Switch Statements

Link to the challenge:

Carefully read the requirements of the challenge again:

Write a switch statement which tests val and sets answer for the following conditions:
1 - "alpha"
2 - "beta"
3 - "gamma"
4 - "delta"

It’s not asking you to console.log() the results, it’s asking you to set answer based on the result.

1 Like

your function always returns "" instead of the required strings

Figured this out! Thanks so much!

1 Like