Basic JavaScript - Comparisons with the Logical Or Operator

Tell us what’s happening:

I have a small issue in solving the logical or operator question where I have to find code for
if (val <=10 || val>=20){
return “Inside”;
}
return “outside”;

testfunction(29);
gives me o/p inside

Your code so far

// function testLogicalOr(val) {
//   // Only change code below this line

//   if (val) {
//     return "Outside";
//   }

//   if (val) {
//     return "Outside";
//   }

//   // Only change code above this line
//   return "Inside";
// }

// testLogicalOr(15);

function testLogicalOr(val){
  if(val >= 10 || val <= 20){
    return "Inside";
  }
  return "Outside";
}

console.log(testLogicalOr(15))

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36

Challenge Information:

Basic JavaScript - Comparisons with the Logical Or Operator

Welcome to the forum @Harsh-Limbachiya

function testLogicalOr(val){
  if(val >= 10 || val <= 20){
    return "Inside";
  }
  return "Outside";
}

console.log(testLogicalOr(0))

When 0 is passed to the function the if statement evaluates the first condition. 0 is not greater than or equal to 10.

Since you included the OR statement, the second condition is then evaluated. 0 is less than or equal to 20 so "Inside" is returned.

Happy coding