Tell us what’s happening:
Your code so far
function chainToSwitch(val) {
var answer = "";
// Only change code below this line
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 "John":
answer = "";
break;
case 156:
answer = "";
break;
default:
answer = "Ate Nine";
}
chainToSwitch("bob");
chainToSwitch(42);
chainToSwitch(1);
chainToSwitch(99);
chainToSwitch(7);
chainToSwitch("jhon");
chainToSwitch(156);
}
Your browser information:
Your Browser User Agent is: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.2991.0 Safari/537.36
.
Link to the challenge:
Your function isn’t returning the value of answer
.
Hey @krishnanath,
as @kevcomedia mentioned you aren’t returning a value. Also, I think you would have noticed this if your code would have been more readable. Indent your code like this:
function chainToSwitch(val) {
var answer = "";
// Only change code below this line
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 "John":
answer = "";
break;
case 156:
answer = "";
break;
default:
answer = "Ate Nine";
}
return answer;
} // end of function
2 Likes
@krishnanath
Be careful you also mispelled john in your function call as “jhon”, no cap to start and the letters are out of order.
Javascript is case sensitive.
-WWC