I don’t know what I am doing wrong. If anybody can point out the mistakes, I would appreciate it.
function caseInSwitch(val) {
var answer = "val";
// Only change code below this line
switch(val) {
case "1":
"alpha";
break;
case "2":
"beta";
break;
case "3":
"gamma";
break;
case "4":
"delta";
break;
}
// Only change code above this line
return answer;
}
// Change this value to test
caseInSwitch(1);
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36.
The lines like this are not JavaScript commands. They don’t do anything. You are always returning “val” because that is what answer is set to and you return answer.
Also, numbers are different from strings so 1 is not the same as "1".
It is a way to have less code written, a switch statement easily substitute a long line of if…else if statements when you need to do a different thing with different values of a variable