--- id: 56533eb9ac21ba0edf2244d9 title: Comparisons with the Logical Or Operator challengeType: 1 videoUrl: https://scrimba.com/c/cEPrGTN forumTopicId: 16800 localeTitle: Сравнение с логическим или оператором --- ## Description
Логический или оператор ( || ) возвращает true если любой из операндов true . В противном случае возвращается false . Логический или оператор состоит из двух символов трубы ( | ). Обычно это можно найти между клавишами Backspace и Enter. Нижеприведенный рисунок должен выглядеть знакомым с предыдущих точек:
если (num> 10) {
вернуть «Нет»;
}
if (num <5) {
вернуть «Нет»;
}
вернуть «Да»;
вернет «Да» только в том случае, если num находится между 5 и 10 (включено 5 и 10). Та же логика может быть записана как:
если (num> 10 || num <5) {
вернуть «Нет»;
}
вернуть «Да»;
## Instructions
Объедините два оператора if в один оператор, который возвращает "Outside" если val не находится между 10 и 20 , включительно. В противном случае верните "Inside" .
## Tests
```yml tests: - text: You should use the || operator once testString: assert(code.match(/\|\|/g).length === 1); - text: You should only have one if statement testString: assert(code.match(/if/g).length === 1); - text: testLogicalOr(0) should return "Outside" testString: assert(testLogicalOr(0) === "Outside"); - text: testLogicalOr(9) should return "Outside" testString: assert(testLogicalOr(9) === "Outside"); - text: testLogicalOr(10) should return "Inside" testString: assert(testLogicalOr(10) === "Inside"); - text: testLogicalOr(15) should return "Inside" testString: assert(testLogicalOr(15) === "Inside"); - text: testLogicalOr(19) should return "Inside" testString: assert(testLogicalOr(19) === "Inside"); - text: testLogicalOr(20) should return "Inside" testString: assert(testLogicalOr(20) === "Inside"); - text: testLogicalOr(21) should return "Outside" testString: assert(testLogicalOr(21) === "Outside"); - text: testLogicalOr(25) should return "Outside" testString: assert(testLogicalOr(25) === "Outside"); ```
## Challenge Seed
```js 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"; } // Change this value to test testLogicalOr(15); ```
## Solution
```js function testLogicalOr(val) { if (val < 10 || val > 20) { return "Outside"; } return "Inside"; } ```