freeCodeCamp: Comments are not ignored?
Challenge Comparisons with the Logical And Operator has an issue.
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.143 Safari/537.36.
Please describe how to reproduce this issue, and include links to screenshots if possible.
My code:
function testLogicalAnd(val) {
// Only change code below this line
if (val<=50 && val>=25) {
return "Yes";
//
}
// Only change code above this line
return "No";
}
// Change this value to test
testLogicalAnd(10);
I commented out the second if statement and did not pass, this test failed ‘You should only have one if statement’
function testLogicalAnd(val) {
// Only change code below this line
if (val<=50 && val>=25) {
// if (val) {
return "Yes";
// }
}
// Only change code above this line
return "No";
}
// Change this value to test
testLogicalAnd(10);
Removing the if statement all together passed the test:
function testLogicalAnd(val) {
// Only change code below this line
if (val<=50 && val>=25) {
return "Yes";
}
// Only change code above this line
return "No";
}
// Change this value to test
testLogicalAnd(10);
Not sure if this is intended behavior but it felt like a bug, commenting out the second if statement would work under normal circumstances. Thanks.
(Bouncey edited for code formatting)
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 19 (13 by maintainers)
Although this is the oldest, closing in favor of https://github.com/freeCodeCamp/freeCodeCamp/issues/11360 which has more relevant technical discussion.