I get sucked while i use switch case by default

Tell us what’s happening:

Your code so far

function switchOfStuff(val) {
var 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


Your browser information:

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

Challenge: Adding a Default Option in Switch Statements

Link to the challenge:

There’s some errors in your case statements. You are using undeclared variables. For instance case a: is checking if the value in the variable you passed to the switch statement (in this case val) is equal to the value in the a variable, but the a variable hasn’t been declared. The same goes for the others case statements.

I’m assuming you’re trying to check if val is equal to the string "a", "b" or "c". If so, a quick fix would be to put quotes on them. This way, case a: would be corrected to case "a": .

1 Like

i change it but it still look the same way.

You are also missing the return statement in function.

yes,thanks now no debbugs…