Switch staements in javascript

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


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

caseInSwitch(1);

I think i did this correct because the values get returned
correctly but its not passing me :man_facepalming:

There’s a difference between returning a value, and console.logging it.

Make sure your function comply with the request. In your case this function is returning "" an empty string.


Also this language is javascript, and not to be confused with java, a totally different programming language.

It worked by removing console.log with return and removing the parenthesis on the strings. Thanks

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