Selection of Many Options with Switch Statements

Tell us what’s happening:

Your code so far


function caseInSwitch(val) {
  var answer = "";
  // Only change code below this line
   switch (val) {
  case 1:
    Answer = "alpha";
    break;

  case 2:
    Answer = "beta";
    break;

  case 3:
    Answer = "gamma";
    break;

  case 4:
    Answer = "delta";
    break;
  
  // Only change code above this line  
  return answer;  
}

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

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-javascript/selecting-from-many-options-with-switch-statements

In your code, you’re assigning a value to a nonexistent variable called “Answer,” but then you return the variable “answer,” which is always an empty string. Remember: variable names are case-sensitive.

1 Like