Switch statement with default

Switch statement with default
0

why is this not working?

function switchOfStuff(val) {
  var answer = "";
  // Only change code below this line
  switch (val){
  case 'a': 
  answer = 'apple';
  break;
   case 'b': 
  answer = 'bird';
  break;
   case 'c': 
  answer = 'cat';
  break;
   default: 
  answer = 'stuff';
  break;
  // Only change code above this line  
  return answer;  
}
}
// Change this value to test
switchOfStuff('b');

Think about the proper location of the return statement. You changed code below the comment “// Only change code above this line”

I reset the code and pasted back the switch statements it’s still not working properly

I had the closing } in the wrong area, it works now.

1 Like