UI returns an error when the code is correct for challenge “Adding A Default Option in Switch Statements”.
“ReferenceError: a is not defined” occurs because code reads
switchOfStuff(a) when it should read switchOfStuff(“a”) in order to work.
**Your code so far**
function switchOfStuff(val) {
let 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";
break;
}
// Only change code above this line
return answer;
}
switchOfStuff(a);
Should read switchOfStuff(“a”);
**Your browser information:**
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.0.0 Safari/537.36
Challenge: Adding a Default Option in Switch Statements
Link to the challenge: