Basic JavaScript - Selecting from Many Options with Switch Statements

Tell us what’s happening:
the error I get is:

caseInSwitch(1)

should have a value of the string

alpha
caseInSwitch(2)

should have a value of the string

beta
caseInSwitch(3)

should have a value of the string

gamma
caseInSwitch(4)

should have a value of the string

delta

but when I test at the bottom with 1-4, I get these answers as strings.

Your code so far

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

caseInSwitch(1);

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/111.0

Challenge: Basic JavaScript - Selecting from Many Options with Switch Statements

Link to the challenge:

You aren’t changing the value stored in the answer variable

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