Bug in #94? Never set value to a variable that was required

I wasn’t paying attention to the requirements and just started typing. My code produced the correct results but skipped setting a value to the variable “answer”. Is this normal since the return value was correct or is it a bug in the problem.

Your code so far

function caseInSwitch(val) {
  var answer = "";
  // Only change code below this line
  switch (val) {
    case 1:
      return "alpha";
      break;
    case 2:
      return "beta";
      break;
    case 3:
      return "gamma";
      break;
    case 4:
      return "delta";
      break;      
  }
  
  
  // Only change code above this line  
  return answer;  
}

// Change this value to test
caseInSwitch(1);

Your browser information:

Your Browser User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.186 Safari/537.36.

Link to the challenge:
https://www.freecodecamp.org/challenges/selecting-from-many-options-with-switch-statements

No bug. When you use the return statement like below:

  return "alpha"

the function returns the value “alpha” to the calling function and does not execute any further code inside the caseInSwitch function, so the last line of:

  return answer;

never gets executed, so it does not matter you did not change answer’s original value of “” (a blank string). Your function returns the correct value for each test case.