Files
wehub-resource-sync dde272c4b8
i18n - Build Validation / Validate i18n Builds (24) (push) Has been cancelled
CI - Node.js / Lint (24) (push) Has been cancelled
CI - Node.js / Build (24) (push) Has been cancelled
CI - Node.js / Test (24) (push) Has been cancelled
CI - Node.js / Test - Upcoming Changes (24) (push) Has been cancelled
CI - Node.js / Test - i18n (italian, 24) (push) Has been cancelled
CI - Node.js / Test - i18n (portuguese, 24) (push) Has been cancelled
CD - Docker - GHCR Images / Build and Push Images (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 11:55:53 +08:00

2.5 KiB

id, title, challengeType, forumTopicId, dashedName
id title challengeType forumTopicId dashedName
56533eb9ac21ba0edf2244d9 Comparisons with the Logical Or Operator 1 16800 comparisons-with-the-logical-or-operator

--description--

The logical or operator (||) returns true if either of the operands is true. Otherwise, it returns false.

The logical or operator is composed of two pipe symbols: (||). This can typically be found between your Backspace and Enter keys.

The pattern below should look familiar from prior waypoints.

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

This code will return Yes if num is between 5 and 10 (5 and 10 included). The same logic can be written with the logical or operator.

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.

--hints--

You should use the || operator once

assert(__helpers.removeJSComments(code).match(/\|\|/g).length === 1);

You should only have one if statement

assert(__helpers.removeJSComments(code).match(/if/g).length === 1);

testLogicalOr(0) should return the string Outside

assert(testLogicalOr(0) === 'Outside');

testLogicalOr(9) should return the string Outside

assert(testLogicalOr(9) === 'Outside');

testLogicalOr(10) should return the string Inside

assert(testLogicalOr(10) === 'Inside');

testLogicalOr(15) should return the string Inside

assert(testLogicalOr(15) === 'Inside');

testLogicalOr(19) should return the string Inside

assert(testLogicalOr(19) === 'Inside');

testLogicalOr(20) should return the string Inside

assert(testLogicalOr(20) === 'Inside');

testLogicalOr(21) should return the string Outside

assert(testLogicalOr(21) === 'Outside');

testLogicalOr(25) should return the string Outside

assert(testLogicalOr(25) === 'Outside');

--seed--

--seed-contents--

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

--solutions--

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