Hi! What am I doing wrong?

Tell us what’s happening:

I’m stuck at the switch method. researched at MDN^ but still no clue how to pass this step.

Your code so far


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

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

Your browser information:

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

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-javascript/selecting-from-many-options-with-switch-statements/

Looks like on at first glance you are missing your switch statment at the top before the first case statement, i’m also not sure your answer += " is correct I’ll play with it and get back to you but maybe just the switch statement

Just checked and the += worked but I just used
case 1:
answer = “alpha”

1 Like

23

Thanks, mate!

You were right about the switch statement. I was confused, cos in an example switch was similar syntax to function, except for no function word before it. My bad.

Thanks for such a quick hand!

Not a problem, I’m leaning myself and it really helps to answer other peoples question. I’m pretty good with switch because I usually code in TSQL so it’s like a case statement for me. If you need any help give me a shout. Good luck with everything and hang in there it get’s easier (at least I hope it does)

Haha! I usually get stuck on silly things like this one. But google or mdn are helpful enough not to bother good people. Anyway, thank you, and have a good day!

check this link
http://www.w3schools.com

Excellent resource to use:

yeah! that’s a good one.