Java switch statements

Hi everyone,

Can anyone help me with this?

function caseInSwitch(val) {
  var answer = "";
  // Only change code below this line
  switch (answer) {
    case 1:
      consol.log("alpha");
      break;
    case 2:
      console.log("beta");
      break;
    case 3:
      console.log("gamma");
      break;
    case 4:
      console.log("delta");
      break;
    default:
      console.log("default");
      break;
     }
  
  
  // Only change code above this line  
  return answer;  
}

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

It’s from the selecting from many options with Switch Statements challenge, number 190. The guide is the same as the tutorial and when I researched on the internet, it shows exactly how I have written the code but mine is not passing?

Cheers
Mike.

Hi, @M124L.
You don’t need to use consol.log("alpha");
Try to replace it with return "alpha";

Good luck!

I cleaned up your code.
You need to use triple backticks to post code to the forum.
See this post for details.

You’re also using the wrong variable in switch. What goes in switch(..) is the variable that you want to test the value of.

It’s called JavaScript. You can’t abbreviate it to Java. Java is a different language.

Thank you for your help

Thank you for the information, I will remember that in the future.

1 Like

Thank you for the link, I always wondered how to do that :slight_smile:

You’re welcome. It’s unfortunate that they share these 4 letters. Just wanted to help avoid confusion.

1 Like