Javascript problem

Tell us what’s happening:

what’s the problem with the code?

Your code so far


function caseInSwitch(val) {
  var answer = "";
  // Only change code below this line
  switch (val) {
    case val === 1:
    return "alpha";
    break;
  
    case val === 2:
    return "beta";
    break;

    case val === 3:
    return "gamma";
    break;
  
    case val === 4:
    return "delta";
    break;

  }
  
  // Only change code above this line  
    


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

Your browser information:

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

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-javascript/selecting-from-many-options-with-switch-statements

You don’t need to explicitly type val === 1, by typing case it’s already doing the val ===; all you need is to put the value. ex:

case 1:

1 Like