Multiple Identical Options in Switch Statement

Multiple Identical Options in Switch Statement
0

#1

So yeah, I have checked other posts on this lesson and it seems like I have the right code. Not sure why it isn’t working.

Your code so far

function sequentialSizes(val) {
  var answer = "";
  // Only change code below this line
  switch(val) {
    case 1:
    case 2:
    case 3:
      result = "Low";
      break;
    case 4:
    case 5:
    case 6:
      result = "Mid";
      break;
    case 7:
    case 8:
    case 9:
      result = "High";
  }
  
  
  // Only change code above this line  
  return answer;  
}

// Change this value to test
sequentialSizes(1);


#2

Your solution returns a variable named answer, but you are assigning values of “Low”, “Mid”, and “High” to a variable named result.


#3

What in the… I have no idea what I was thinking in that moment. Thanks very much.


#4

Actually, I do know what I was thinking. This is the example from the lesson:

switch(val) {
case 1:
case 2:
case 3:
result = “1, 2, or 3”;
break;
case 4:
result = “4 alone”;
}


I get that it’s the principle they are teaching, but you would think they could make it consistent for the sake of learning.