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

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/

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

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

1 Like