Js JavaScript: Comparisons with the Logical Or Operator

the error is
testLogicalOr(10) should return “Inside”

testLogicalOr(15) should return “Inside”

testLogicalOr(19) should return “Inside”

testLogicalOr(20) should return “Inside”

function 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(19);

**Link to the challenge:**
https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/basic-javascript/comparisons-with-the-logical-or-operator

You should combine the given two if statement like this:

if (num > 10 || num < 5) {
  return "No";
}
return "Yes";

If I pass the value 11 to your function, it will return Outside. Why? Because your if statement checks if either of the two conditions are met, then return Outside. The second condition val > 10 would be true because 11 is greater than 10.

1 Like

thanks, I wasnt attentive to the task …

Also you are not supposed to be returning ‘Inside’ or ‘Outside’. Look at the instructions for what to return.

1 Like