Basic JavaScript - Selecting from Many Options with Switch Statements

So I typed this up before I came here and saw that this is one of the solutions. I thought maybe I had a syntax error so instead of searching and racking my brain I ran the code through my IDE Visual Studio Code and all I did was copy and paste. I passed it all the same arguments and worked just fine. For some reason the freeCodeCamp’s code editor is returning the error that it’s not returning the right statements. So I think probably I didn’t type the words properly it happens sometimes, but then after checking every character they are the same. It is a little frustrating since I know the code Does in fact do what it’s supposed to…

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) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36 Edg/113.0.1774.57

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

Link to the challenge:

Console logging isn’t the same thing as returning

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