* chore(learn): audit basic algorithm scripting * chore(learn): audit basic data structures * chore(learn): audit basic javascript * chore(learn): audit debugging * chore(learn): audit es6 * chore(learn): audit functional programming * chore(learn): audit intermidate algorithms * chore(learn): audit js projects * chore(learn): audit object oriented programming * chore(learn): audit regex * fix(learn): remove stray . * fix(learn): string to code * fix(learn): missed some * fix(learn): clarify strings Based on Randy's feedback, clarifies string instances where quotes were removed in favour of back ticks. * fix: apply suggestions - thanks Randy! :) Co-authored-by: Randell Dawson <5313213+RandellDawson@users.noreply.github.com> * fix: non-suggestion comments * chore(learn): remove comments from codes Removes the comments from the description and instruction code blocks to ensure that all relevant information is translatable. * fix: Apply suggestions from code review Co-authored-by: Shaun Hamilton <51722130+ShaunSHamilton@users.noreply.github.com> * fix: revert crowdin fix * Update curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-algorithm-scripting/mutations.md Co-authored-by: Randell Dawson <5313213+RandellDawson@users.noreply.github.com> * fix: Apply suggestions from code review Co-authored-by: Shaun Hamilton <51722130+ShaunSHamilton@users.noreply.github.com> * Update curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-to-assign-variables-from-arrays.md Co-authored-by: Shaun Hamilton <51722130+ShaunSHamilton@users.noreply.github.com> * fix: Apply suggestions from code review Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com> Co-authored-by: Shaun Hamilton <51722130+ShaunSHamilton@users.noreply.github.com> * chore: change voice * fix: Christopher Nolan * fix: expressions would evaluate * fix: will -> would * Update curriculum/challenges/english/02-javascript-algorithms-and-data-structures/object-oriented-programming/add-methods-after-inheritance.md Co-authored-by: Randell Dawson <5313213+RandellDawson@users.noreply.github.com> * fix: to work to push * Update curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/iterate-with-javascript-for-loops.md Co-authored-by: Shaun Hamilton <51722130+ShaunSHamilton@users.noreply.github.com> * Update curriculum/challenges/english/02-javascript-algorithms-and-data-structures/object-oriented-programming/add-methods-after-inheritance.md Co-authored-by: Randell Dawson <5313213+RandellDawson@users.noreply.github.com> Co-authored-by: Randell Dawson <5313213+RandellDawson@users.noreply.github.com> Co-authored-by: Shaun Hamilton <51722130+ShaunSHamilton@users.noreply.github.com> Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com>
2.4 KiB
id, title, challengeType, videoUrl, forumTopicId, dashedName
id | title | challengeType | videoUrl | forumTopicId | dashedName |
---|---|---|---|---|---|
56533eb9ac21ba0edf2244d9 | Comparisons with the Logical Or Operator | 1 | https://scrimba.com/c/cEPrGTN | 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";
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
.
--hints--
You should use the ||
operator once
assert(code.match(/\|\|/g).length === 1);
You should only have one if
statement
assert(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";
}