Replacing If Else Chains with Switch Help

Okay so its saying to switch the code from else/if to switch which i believe i have ill add that code below as im not sure where i have gone wrong.

switch (val) {
case 1:
answer = “Marley”;
break;
case 2:
answer = “The Answer”;
break;
case 3:
answer = “There is no #1”;
break;
case 4:
answer = “Missed me by this much!”;
break;
case 5:
answer = “Ate Nine”;
break;
}

Your code so far


function chainToSwitch(val) {
  var answer = "";
  // Only change code below this line
  
  if (val === "bob") {
    answer = "Marley";
  } else if (val === 42) {
    answer = "The Answer";
  } else if (val === 1) {
    answer = "There is no #1";
  } else if (val === 99) {
    answer = "Missed me by this much!";
  } else if (val === 7) {
    answer = "Ate Nine";
  }
  
  // Only change code above this line  
  return answer;  
}

// Change this value to test
chainToSwitch(7);

Your browser information:

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

Where do you have this? Because in “your code so far” there is the if/else chain

Also, you are not using the right numbers, this code say for example "when val === 5 then answer = "Ate Nine" but if you look at the if/else chain that is not when you should get that result

replace if-else with switch man

Just to mention ELSE (last condition) is replaced with DEFAULT in the Switch Case Statement