No idea what is the issue here with this piece of code

No idea what is the issue here with this piece of code
0

#1

Tell us what’s happening:

Your code so far


function switchOfStuff(val) {
  var answer = "";
  // Only change code below this line
   switch(answer)
  {
    case "a":
    answer="apple";
    break; 

    case "b":
    answer= "bird";
    break;

    case "c":
   answer= "cat";
    break;

    default:
    answer= "stuff";
  }
  
  
  // Only change code above this line  
  return answer;  
}

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

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-javascript/adding-a-default-option-in-switch-statements/


#2

In your switch statement you reference the answer variable. If you look above 2 lines before that, answer has been initialized as a blank string. Should you really being using answer in your switch?


#3

Without referencing the answer variable, many of the test cases fail so I went ahead and referenced it.


#4

Hey you were right. I should have used the variable val in my switch instead of answer.