Error in your code/instructions

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";
case "b":
  answer = "bird";
case "c":
  answer = "cat";
  answer = "stuff";
// Only change code above this line
return answer;


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/ Safari/537.36

Challenge: Adding a Default Option in Switch Statements

Link to the challenge:

You haven’t defined a variable named a so you can’t use the variable a in that function call. But you can pass in the string “a”.

1 Like

Thank you - that’s fine - but your UI instructs the user not to make any changes below a particular comment. I had to make changes below the comment (add inverted commas around the a) to get my code to pass.
Remember you’re dealing with novices here - we don’t understand what we’re doing, but we are told to trust your instructions, but in this case it was necessary to ignore your instructions to pass your test.

You changed that line from what you were given


It really was not.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.