Conflicting Lesson Answers Which Way Is Correct? SOLVED

The following code gave me the correct answer to the Javascript lesson Multiple Identical Options in Switch Statements. However, the previous lesson, Adding a Default Option in Switch Statements, would not give me a correct answer until all the switch statement case numbers were in quotation marks. This seems like conflicting information.

Both correct code lessons are included here. Notice the difference in the switch statement case. Which way is correct?


function sequentialSizes(val) {
let answer = "";
// Only change code below this line
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";
}

// Only change code above this line
return answer;
}

sequentialSizes(1);

Previous Lesson Code

  **Your browser information:**

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

Challenge: Multiple Identical Options in Switch Statements

Link to the challenge:

Those don’t look like numbers to me, they look like letters, which would need to be in quotes since they are strings. But maybe I’m not understanding your question correctly?

1 Like

I think you are right. I have only been coding for about 15hrs. Thank you for helping me understand.

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