Selecting from many options with Switch Statements, tell me I'am wrong- help!

Tell us what’s happening:
Why is it saying that the task is not fullfilled? I did what it wanted from me.

Your code so far

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

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

Your browser information:

Your Browser User Agent is: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:55.0) Gecko/20100101 Firefox/55.0.

Link to the challenge:
https://www.freecodecamp.org/challenges/selecting-from-many-options-with-switch-statements

that functions returning the value from variable answer

you initialized answer with the value of ‘1’, and I believe that challenge wants you to assign the answer when the val is 1,2,3 or 4 to an ‘alpha’, ‘beta’, ‘gamma’ or ‘delta’ respectively before returning it ( you already return the answer at the end of the function return answer). so just need to assign the var answer to the corresponding string.

example of assignment :
answer = "some string"

hope this helps

1 Like