Basic JavaScript - Adding a Default Option in Switch Statements

Tell us what’s happening:
Describe your issue in detail here.
My code is looking so correct but doesn’t pass… Please can you help
Your code so far

function switchOfStuff(val) {
  let answer = "";
  // Only change code below this line
switch (answer) {
  case "a":
   answer = "apple";
   break;
 case "b":
   answer = "bird";
   break;
 case "c":
   answer = "cat";
   break;
  default:
  answer = "stuff";
  

}


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

switchOfStuff(1);

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36

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

Link to the challenge:

Hi @eyehifeanyichukwu ,

Take a closer look at the variable that is being tested by the switch statement.

1 Like

I still can’t find anything please help

You are soooo close. Double check the switch parameter.

Sure. Take a look at how the function is being called below.

switchOfStuff(1);

The switch statement should be testing to see if the value passed to the function matches any of the cases. Here the value being passed is 1.

Now take a look here:

switch (answer) {

The switch statement is currently testing the wrong variable