It tests for if statements to prevent me from using those.
But it does not prevent me from using ternary operator as i did in this challenge.
Challenge Multiple Identical Options in Switch Statements has an issue.
User Agent is: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.99 Safari/537.36
.
Please describe how to reproduce this issue, and include links to screenshots if possible.
My code:
function sequentialSizes(val) {
var answer = "";
// Only change code below this line
answer = (val >= 1 && val <= 3) ? "Low" : answer;
answer = (val >= 4 && val <= 6) ? "Mid" : answer;
answer = (val >= 7 && val <= 9) ? "High" : answer;
switch (null) {
case '':case '':case '':case '':case '':case '':case '':case '':case '':
}
// Only change code above this line
return answer;
}
// Change this value to test
sequentialSizes(1);
Nice work @darkflikk! 馃槃 Thanks for reporting this issue.
I'm not sure if we should fix this, as we don't talk about ternary operators before this challenge.
Adding tests for ternary operators could potentially break other things. I think the easiest way to check it would be to simply look for question marks, possibly also for a colon after it separated by some spaces and word characters, but that could mess things up with text in comments again.
@FreeCodeCamp/moderators Any input?
@darkflikk kudos on your efficient solution! For the intended audience and what the challenge is teaching, I don't think there should be any changes. The challenge here is to teach the concept of switch
statements versus using if
statements. Although I don't like the idea of a challenge hindering an individual's creativity in coding up a solution, I think this challenge is sufficient to just teach switch
statements and there's no need to account for ternary solutions.
Just to add on the comments made by @erictleung and @systimotic, a lot of effort has gone in to navigating the tests so that the challenge passes with a ternary instead.
Thanks again for reporting the issue @darkflikk! It is very much appreciated.
Happy coding!
Most helpful comment
@darkflikk kudos on your efficient solution! For the intended audience and what the challenge is teaching, I don't think there should be any changes. The challenge here is to teach the concept of
switch
statements versus usingif
statements. Although I don't like the idea of a challenge hindering an individual's creativity in coding up a solution, I think this challenge is sufficient to just teachswitch
statements and there's no need to account for ternary solutions.