Hi! What am I doing wrong?

Hi! What am I doing wrong?
0.0 0

#1

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/


#2

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”


#3

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!


#4

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)


#5

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!


#6

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

Excellent resource to use:


#7

yeah! that’s a good one.