Stumped on "Comparisons with the Logical Or Operator"

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.

Link to the challenge:

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);
1 Like

As it is your condition will evaluate to true no matter what value you give it. For example 15:

15 > 10 => true
15 < 20 => true

true || true => true

With 1000:

1000 > 10 => true
1000 < 20 => false

true || false => true

You need to use:

!(val<10 || val>20)

as your condition to determine if it is inside.

1 Like
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";
}
1 Like

@nr-mihaylov Thanks, I am making slow progress!

@michal9909 Thanks! I am making slow progress!

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

Solution :
unction testLogicalOr(val) {

// Only change code below this line

if (val > 20 || val < 10) {

return “Outside”;

}

// Only change code above this line

return “Inside”;

}

// Change this value to test

testLogicalOr(15);