Basic JavaScript - Multiple Identical Options in Switch Statements

Tell us what’s happening:
i tried displaying the result on console its not working whats wrong with my code

Your code so far

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

  // Only change code above this line
  return answer;


Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:108.0) Gecko/20100101 Firefox/108.0

Challenge: Basic JavaScript - Multiple Identical Options in Switch Statements

Link to the challenge:

Please reread this part of the exercise:

Write a switch statement to set answer for the following ranges:

If you look in the console, you should see an error message that says ‘Val is not defined’

You are getting that error messsage because you placed the console.log outside of the function and val is a function parameter and not defined outside of that function.

If you move the console.log statement in the beginning of your function then you will see the console output you are looking for.

Also as a sidenote, you don’t need to use break statements when a return is present.
Remember that the return keyword will exit the function so the break statement will not be reached.

Hope that helps!

1 Like

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