Basic JavaScript - Adding a Default Option in Switch Statements

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

This is the solution in the hint and yet I am getting an “a”, “b”, and “c are not defined”. Why is this happening? The challenge Test is also asking for a “d” why would that be expected if not part of the directions?

  **Your code so far**
function switchOfStuff(val) {
let 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
return answer;


Link to the challenge:

you just have a small mistake.
remove the last break; line

the reason the test uses ‘d’ is to see if your code will give the ‘default’ answer
default is what happens for anything that is not explicitly checked by the switch
so a/b/c are all explicitly checked, d is not, so it should go to the default block

There is nothing wrong with using a break for the default case.


I may have duped myself. I was running a noscript plugin and had not given full permissions to FCC. The challenge was completed when i finally did so. I don’t think there’s anything wrong with the answer.

Thank you for your responses.


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