Basic JavaScript - Multiple Identical Options in Switch Statements

Tell us what’s happening:

The code is exactly the same as the example in the video but it doesn’t work. However, if I copy the code from the video and paste it then it works.

I don’t understand why this happens. This the code from the video:

function sequentialSizes(val) {
let answer = “”;
switch(val) {
case 1:
case 2:
case 3:
answer = “Low”;
break;
case 4:
case 5:
case 6:
answer = “Mid”;
break;
case 7:
case 8:
case 9:
answer = “High”;
break;
}
return answer;
}

   **Your code so far**
function sequentialSizes(val) {
 let answer = "";
Switch(val)  {
 case 1:
 case 2:
 case 3:
  answer = "Low";
  break;
 case 4:
 case 5:
 case 6:
  answer = "Mid";
  break;
 case 7:
 case 8:
 case 9:
  answer = "High";
  break;
}
 return answer;
}

console.log(sequentialSizes(1));

   **Your browser information:**

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36

Challenge: Basic JavaScript - Multiple Identical Options in Switch Statements

Link to the challenge:

If it doesn’t work, then it’s not the same. Computers don’t pick on people.

What is “Switch”?

Hint: JS is case sensitive.

:upside_down_face: It was just one capitalization error?!

Thank you so much!

Computer languages are very exact. They aren’t good at guessing what you mean.

Join the club. A big part of being a coder is pounding your head on the desk wondering why it isn’t working.

Well, then I wish I started pounding my head a lot earlier!

Thank you, once again.

1 Like