Tell us what’s happening:
Dear community,
First Happy Sunday to everyone
i wish you all a lovely weekend.
I am practicing Js and i got to solve the exercise of selecting from many options with Switch Statements, but i have some questions in regard of it.
In the part of Case values, the text says case values are tested with strict equality (===).
If it is so, why in the solution part we can´t use strict equality symbol? because it only works with
the symbol of assignment operator (=). Or perhaps when it says sets answer , it refers that we need to use the assignment operator ?.
Thank you all for the orientation and advise in this topic,
Kind regards,
Ivonne
Your code so far
function caseInSwitch(val) {
var answer = "";
// Only change code below this line
switch(val){
case 1:
answer = "alpha";
break;
case 2:
answer = "beta";
break;
case 3:
answer = "gamma";
break;
case 4:
answer = "delta";
break;
}
return answer;
}
// Only change code above this line
// 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/79.0.3945.117 Safari/537.36.
Challenge: Selecting from Many Options with Switch Statements
Your code has been blurred out to avoid spoiling a full working solution for other campers who may not yet want to see a complete solution. In the future, if you post a full passing solution to a challenge and have questions about it, please surround it with [spoiler] and [/spoiler] tags on the line above and below your solution code.
Dear @ibnlanre,
Thank you so much for the kind reply and the easy understandable explanation
about the usage of switch and break.
I appreciate it , thank you again and i wish you a blessed day,
kind regards,
Ivonne