Tell us what’s happening:
why do we need var answer="" as it not related to switch statement and finally “return answer” is present when we have not stored the switch answers in it
Your code so far
function switchOfStuff(val) {
var answer = "";
// Only change code below this line
switch(val){
case "a":
return "apple";break;
case "b":
return "bird";break;
case "c":
return "cat";break;
default "stuff";
break;
}
// 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 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.117 Safari/537.36
.
Challenge: Adding a Default Option in Switch Statements
Link to the challenge:
https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/basic-javascript/adding-a-default-option-in-switch-statements