Selecting from many options with Switch Statements. What is wrong with this?

Selecting from many options with Switch Statements. What is wrong with this?
0

#1

Hi,

I wonder what is wrong with my code:

function caseInSwitch(val) {
var answer = “”;
// Only change code below this line
switch (val) {
case 1:
console.log(“alpha”);
break;
case 2:
console.log(“beta”);
break;
case 3:
console.log(“gamma”);
break;
case 4:
console.log(“delta”);
break;

}

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

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


#2

Hi, you only console.log in the switch statement. You don’t change answer, so it will run and return "" (because it hasn’t changed). So instead of using console.log assign a value to answer for every case.