I need help....nothing is working

Tell us what’s happening:

Your code so far


function caseInSwitch(val) {
var answer = “”;
// Only change code below this line

switch (val) {
case 1:
if(val === 1){ answer = “alpha”; return answer; }

break;
case 2:
if(val === 2){ answer = “beta”; return answer; }
break;
case 3:
if(val === 3){ answer = “gamma”; return answer; }
break;
case 4:
if(val === 4){ answer = “delta”; return answer; }
break;
}

// Only change code above this line

}

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

I have been working on this code for well over an hour. I resorted to even copying and pasting answers that were given in the ‘hints’ section that were confirmed as correct. Yet, nothing worked for me. I refreshed my page and tried numerous things out of desperation. I need help.

Your browser information: Chrome

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

Challenge: Selecting from Many Options with Switch Statements

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

Your code is okay, but be aware … in programming you will use these double quotes " " not the “calligraphic” ones.

So… do you see the lines in the code that say

var answer;
// Only change the code below this line


// Only change the code above this line
return answer;

The key lines are the commented ones. The code you are being asked to write is within those two lines. So the return answer; you’re adding in there? you shouldn’t.

Second, the

if(val === 1){...}

or each if() you do in there? They serve no purpose. The exercise is telling you, when the switch statement hits your case line, it is using the strict compare. So when the execution gets to case 1:, it is checking if val is STRICTLY equal to 1. Then you are checking the exact same thing. Again. Don’t need to.

Each case statement should contain exactly two lines: one setting answer to a value, and one break. More than that isn’t necessary, and could be compromising the test results.

As @laurentiutibea notes, do use either single quotes or double quotes (either ' or "), but not curly quotees. Some phones and/or tablets do those automatically when you’re typing in text, you’ll want to disable that…