Basic JavaScript - Adding a Default Option in Switch Statements

*Tell us what’s happening:
i tried all the hints but still cant reach it

  **Your code so far**
function switchOfStuff(val) {
let answer = "";

switch (val) {
case "a":
 answer = "apple";
 break;
case "b":
 answer = "bird";
 break;
case "c"
 answer = "cat";
 break;
default:
 answer = "stuff";
}
// Only change code below this line
// 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/104.0.5112.81 Safari/537.36 Edg/104.0.1293.47

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

Link to the challenge:

This is from the assignment code editor:

let answer = “”;
// Only change code below this line

// Only change code above this line
return answer;

I guess the code you are writing (the switch statement, etc.) needs to be between the two comments.

Im getting an error that gives a big hint to what is wrong:

SyntaxError: unknown: Unexpected token, expected ":" (12:1)

  10 |  break;
  11 | case "c"
> 12 |  answer = "cat";
     |  ^
  13 |  break;
  14 | default:
  15 |  answer = "stuff";

Take a closer look at your case “c”

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