To Use this Template:
NOTE: ISSUES ARE NOT FOR CODE HELP - Ask for Help at https://gitter.im/FreeCodeCamp/Help
1.) When using strict equality operators the Javascript console, the console flags these and provides and red error X. The code will not run using a strict equality operator.
2.) The W3C examples http://www.w3schools.com/js/js_switch.asp show an assignment operator being used, which my code below also uses and passes the test.
I'm still learning, but hopefully this helps and the corrections can be made. Thanks!
function myTest(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;
}
// Only change code above this line
return answer;
}
// Change this value to test
myTest(1);
case values are tested with a strict equality operator (===)
means that
switch (val) {
case 1:
is equivalent to if (val === 1)
not that everything inside your case needs to be strict equality.
Please visit the Help Chat if you need further clarification. Thanks and happy coding!
Awesome thanks!
Sent from my iPhone
On Feb 24, 2016, at 3:01 PM, Logan Tegman [email protected] wrote:
case values are tested with a strict equality operator (===)
means that
switch (val) {
case 1:
is equivalent to if (val === 1) not that everything inside your case needs to be strict equality.Please visit the Help Chat if you need further clarification. Thanks and happy coding!
—
Reply to this email directly or view it on GitHub.
I looke at the code above but was not able to make the code work with strict equality but this is my code if people have questions or think it is wrong please leave me a comment.
`
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;
}
// Only change code above this line
return answer;
}
// Change this value to test
caseInSwitch(2);
`
Most helpful comment
means that
is equivalent to
if (val === 1)
not that everything inside your case needs to be strict equality.Please visit the Help Chat if you need further clarification. Thanks and happy coding!