Tell us what’s happening:
I don’t really have an issue with this exercise per se but I was wondering why the values were written in quotation marks in this exercise but not in the last one. If you remember in the last one the code was
switch(val){
case 1:
answer = “alpha”;
break;
now this time you had to put the values in quotation marks or it wouldn’t work:
case “a”:
answer = “apple”;
break;
Can anybody tell me why?
Your code so far
function switchOfStuff(val) {
let answer = "";
// Only change code below this line
switch (val){
case "a":
answer = "apple";
break;
case "b":
answer = "bird";
break;
case "c":
answer = "cat";
break;
default:
answer = "stuff";
break;
}
// Only change code above this line
return answer;
}
switchOfStuff(1);
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.4.1 Safari/605.1.15
Challenge: Basic JavaScript - Adding a Default Option in Switch Statements
Link to the challenge: