Plz help me ... i m hang on this

Plz help me ... i m hang on this
0

#1

Tell us what’s happening:

Your code so far



  switch(val){
  case bob:
  answer = "Marley";
  break;
  
  case 42:
  answer = "The Answer";
  break;

  case 1:
  answer = "There is no #1";
  break;

  case 99:
  answer ="Missed me by this much!";
  break;

  default:
  answer ="Ate Nine";
  break;
  
  
  }



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

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

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:61.0) Gecko/20100101 Firefox/61.0.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-javascript/replacing-if-else-chains-with-switch/


#2

Two mistakes I’ve seen from your code above. First Case bob needs to be a string “bob”. Second, because there’s no Else statement toward the end of the original If/Else-If statement the last statement should be another case: 7 answer = “Ate Nine”;.
Hope that helps. Happy coding!

switch (val) {
    case "bob":
    answer = "Marley";
    break;
    case 42:
    answer = "The Answer";
    break;
    case 1:
    answer = "There is no #1";
    break;
    case 99:
    answer = "Missed me by this much!";
    break;
    case 7:
    answer = "Ate Nine";
    break;
    
  }

#3

Hey @khoap86,

The way you have described the mistake of OP is great.
However, you should not give a working solution to question and give OP a chance to figure out the solution on his own.

Happy coding!!!:slightly_smiling_face: