4.1 KiB
4.1 KiB
id | title | challengeType | videoUrl | localeTitle |
---|---|---|---|---|
56533eb9ac21ba0edf2244d9 | Comparisons with the Logical Or Operator | 1 | مقارنات مع المنطقي أو المشغل |
Description
||
) true
إذا كان أي من المعاملات true
. خلاف ذلك ، فإنها ترجع false
. المنطقي أو المشغل يتكون من اثنين من رموز الأنبوب ( |
). يمكن العثور على ذلك عادةً بين مفتاحي Backspace و Enter. يجب أن يبدو النمط أدناه مألوفًا من نقاط الطريق السابقة: if (num> 10) {سيعود "نعم" إلا إذا
العودة "لا" ؛
}
إذا (عدد <5) {
العودة "لا" ؛
}
العودة "نعم" ؛
num
ما بين 5
و 10
(5 و 10 مدرجة). نفس المنطق يمكن كتابته على النحو التالي: if (num> 10 || num <5) {
العودة "لا" ؛
}
العودة "نعم" ؛
Instructions
if
في عبارة واحدة والتي تُرجع "Outside"
إذا لم يكن val
ما بين 10
و 20
ضمناً. خلاف ذلك ، والعودة "Inside"
. Tests
tests:
- text: يجب عليك استخدام <code>||</code> عامل مرة واحدة
testString: 'assert(code.match(/\|\|/g).length === 1, "You should use the <code>||</code> operator once");'
- text: يجب أن يكون لديك واحد فقط <code>if</code> البيان
testString: 'assert(code.match(/if/g).length === 1, "You should only have one <code>if</code> statement");'
- text: يجب أن ترجع <code>testLogicalOr(0)</code> "خارج"
testString: 'assert(testLogicalOr(0) === "Outside", "<code>testLogicalOr(0)</code> should return "Outside"");'
- text: يجب أن ترجع <code>testLogicalOr(9)</code> "خارج"
testString: 'assert(testLogicalOr(9) === "Outside", "<code>testLogicalOr(9)</code> should return "Outside"");'
- text: <code>testLogicalOr(10)</code> إرجاع "Inside"
testString: 'assert(testLogicalOr(10) === "Inside", "<code>testLogicalOr(10)</code> should return "Inside"");'
- text: <code>testLogicalOr(15)</code> إرجاع "Inside"
testString: 'assert(testLogicalOr(15) === "Inside", "<code>testLogicalOr(15)</code> should return "Inside"");'
- text: <code>testLogicalOr(19)</code> إرجاع "Inside"
testString: 'assert(testLogicalOr(19) === "Inside", "<code>testLogicalOr(19)</code> should return "Inside"");'
- text: <code>testLogicalOr(20)</code> إرجاع "Inside"
testString: 'assert(testLogicalOr(20) === "Inside", "<code>testLogicalOr(20)</code> should return "Inside"");'
- text: يجب أن ترجع <code>testLogicalOr(21)</code> "خارج"
testString: 'assert(testLogicalOr(21) === "Outside", "<code>testLogicalOr(21)</code> should return "Outside"");'
- text: يجب أن ترجع <code>testLogicalOr(25)</code> "خارج"
testString: 'assert(testLogicalOr(25) === "Outside", "<code>testLogicalOr(25)</code> should return "Outside"");'
Challenge Seed
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
// solution required