Basic JavaScript - Adding a Default Option in Switch Statements

I can’t seem to figure out what I did wrong, my code seems correct, yet I can’t pass the tests

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: stuff
  break;
}

  // Only change code above this line
  return answer;
}

switchOfStuff(a);

Your browser information:

User Agent is: Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Mobile Safari/537.36

Challenge: Basic JavaScript - Adding a Default Option in Switch Statements

Link to the challenge:

You’ve written the variable stuff as the default. The code will get to that and try to evaluate stuff.

Also you don’t break on default; it’s the default and only runs if no other branch matches, there’s nothing to break from.

1 Like