Tell us what’s happening: I understand that any inclusive number should be correct. I also understand the basic syntax based on the example. However, it doesn’t pass the tests. I also tried > 10 and < 20, and got the same errors below. Thanks in advance!
I am missing these 4 points:
testLogicalOr(10) should return "Inside"
testLogicalOr(15) should return "Inside"
testLogicalOr(19) should return "Inside"
testLogicalOr(20) should return “Inside”
Your code so far
function testLogicalOr(val) {
// Only change code below this line
if (val < 20 || val > 10) {
return "Outside";
} {
return "Outside";
}
// Only change code above this line
return "Inside";
}
// Change this value to test
testLogicalOr(15);
Your browser information:
Your Browser User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:55.0) Gecko/20100101 Firefox/55.0.
Combine the two if statements into one statement which returns “Outside” if val is not between 10 and 20, inclusive. Otherwise, return “Inside”.
You need to use NOT (!) operator to solve this problem
Solution
function testLogicalOr(val) {
// Only change code below this line
if (!(val > 20 || val < 10)) {
return "Inside";
}
// Only change code above this line
return "Outside";
}
// Change this value to test
testLogicalOr(15);
Is this any closer? I had to keep with the ! operator because I am down to only three requirements which haven't been met:
testLogicalOr(10) should return "Inside"
testLogicalOr(15) should return "Inside"
testLogicalOr(19) should return "Inside"
if ((val > 10 || val < 20)) {
return "Inside";
}
// Only change code above this line
return "Outside";
}
My apologies. Sometimes it takes a 2nd or third look for me. I finally got it right! Yay! Now, I get to have dinner and chill. Thanks again! @camperextraordinaire, @nr-mihaylov, @michal9909