function switchOfStuff(val) {
var answer = "";
// Only change code below this line
switch (val) {
case a:
answer = "apple";
break;
case b:
answer = "bird";
break;
case c:
answer = "cat";
break;
default:
answer = "stuff";
}
}
// Only change code above this line
switchOfStuff(1);
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36.
Challenge: Adding a Default Option in Switch Statements
There’s some errors in your case statements. You are using undeclared variables. For instance case a: is checking if the value in the variable you passed to the switch statement (in this case val) is equal to the value in the a variable, but the a variable hasn’t been declared. The same goes for the others case statements.
I’m assuming you’re trying to check if val is equal to the string "a", "b" or "c". If so, a quick fix would be to put quotes on them. This way, case a: would be corrected to case "a": .