Basic JavaScript - Multiple Identical Options in Switch Statements

Tell us what’s happening:
Having issue of result is not defined. what is the way forward?

Your code so far

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

sequentialSizes(1);

Your browser information:

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

Challenge: Basic JavaScript - Multiple Identical Options in Switch Statements

Link to the challenge:

You are returning answer from your function, but you haven’t assigned it a value (other than an empty string). You will be getting an undefined error because you are attempting to assign values to result (within your switch function), but you never declared result in the first place.

Inside your switch statement, you should be assigning values to answer instead.

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