Basic JavaScript - Adding a Default Option in Switch Statements

Tell us what’s happening:
Describe your issue in detail here.

Your code so far
i need help with default switch statement

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;

  case "d":
  answer = "stuff";
  break;

  case 4:
  answer = "stuff";
  break;

  default:
  "stuff";
  break
}


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

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

Link to the challenge:

What do you want to do with that string?

i want to set a default statement. that’s why i used that string

That string is just floating around doing nothing though

so what should i do to set the default statement

Which value do you want to set as the default value?

“stuff” is the value i want to set as defualt

what do you want to do with the string "stuff"? Do you want to assign this value to some variable or just print it to the console or something else?

1 Like

my task require me to set it as default value, possibly to print it out as default value

set it as a default value basically means that you need to assign it to some variable.


Read the first line.
Note: Here answer is a name of a variable.

thanks i have got it

1 Like

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