Tell us what’s happening:
My code passes fine and I thought I understood what the Logical Or Operator was about, but I am confused with the wording of the example and the instructions here. Feels like I’m missing something.
The exercise is using < and > here, and yet I’m reading that it will be inclusive of the numbers after those angle brackets. If that is true, why are we not using <= and >= instead?
Am I misunderstanding something? Do the Less Than/Equal Than angle brackets behave differently when between these two pipe symbols (||) ? If not, why is it implied that they are behaving as Less/Greater Than Or Equal? Or is this a typo in the example and instructions, held over from a previous problem that does use <= / >= ?
Feels like I’m having a stroke! I tried to bold the relevant words below to draw attention to what I’m referring to - any insight appreciated. Thanks!
From the example:
if (num > 10) {
return "No";
}
if (num < 5) {
return "No";
}
return "Yes";
will return Yes
only if num
is between 5
and 10
(5 and 10 included). The same logic can be written as:
if (num > 10 || num < 5) {
return "No";
}
return "Yes";
–
Instructions:
Combine the two if
statements into one statement which returns the string Outside
if val
is not between 10
and 20
, inclusive. Otherwise, return the string Inside
.
Your code so far
function testLogicalOr(val) {
// Only change code below this line
if (val > 20 || val < 10) {
return "Outside";
}
// Only change code above this line
return "Inside";
}
testLogicalOr(15);
**Your browser information:**
User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.64 Safari/537.36
Challenge: Comparisons with the Logical Or Operator
Link to the challenge: