3.9 KiB
3.9 KiB
id | title | challengeType | videoUrl | localeTitle |
---|---|---|---|---|
56533eb9ac21ba0edf2244d8 | Comparisons with the Logical And Operator | 1 | مقارنات مع المنطقية والمشغل |
Description
&&
) true
إذا وفقط إذا كانت المعاملات إلى اليسار واليمين صحيحاً. يمكن تحقيق نفس التأثير بتضمين جملة if داخل أخرى إذا: if (num> 5) {سيعود فقط "نعم" إذا
إذا (عدد <10) {
العودة "نعم" ؛
}
}
العودة "لا" ؛
num
أكبر من 5
وأقل من 10
. نفس المنطق يمكن كتابته على النحو التالي: if (num> 5 & num <10) {
العودة "نعم" ؛
}
العودة "لا" ؛
Instructions
"Yes"
إذا كان val
أقل من أو يساوي 50
وأكبر من أو يساوي 25
. خلاف ذلك ، سيعود "No"
. 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>testLogicalAnd(0)</code> "لا"
testString: 'assert(testLogicalAnd(0) === "No", "<code>testLogicalAnd(0)</code> should return "No"");'
- text: <code>testLogicalAnd(24)</code> يجب أن ترجع "لا"
testString: 'assert(testLogicalAnd(24) === "No", "<code>testLogicalAnd(24)</code> should return "No"");'
- text: <code>testLogicalAnd(25)</code> يجب أن ترجع "Yes"
testString: 'assert(testLogicalAnd(25) === "Yes", "<code>testLogicalAnd(25)</code> should return "Yes"");'
- text: يجب أن ترجع <code>testLogicalAnd(30)</code> "نعم"
testString: 'assert(testLogicalAnd(30) === "Yes", "<code>testLogicalAnd(30)</code> should return "Yes"");'
- text: يجب أن ترجع <code>testLogicalAnd(50)</code> "نعم"
testString: 'assert(testLogicalAnd(50) === "Yes", "<code>testLogicalAnd(50)</code> should return "Yes"");'
- text: <code>testLogicalAnd(51)</code> يجب أن ترجع "لا"
testString: 'assert(testLogicalAnd(51) === "No", "<code>testLogicalAnd(51)</code> should return "No"");'
- text: يجب أن <code>testLogicalAnd(75)</code> "لا"
testString: 'assert(testLogicalAnd(75) === "No", "<code>testLogicalAnd(75)</code> should return "No"");'
- text: <code>testLogicalAnd(80)</code> يجب أن ترجع "لا"
testString: 'assert(testLogicalAnd(80) === "No", "<code>testLogicalAnd(80)</code> should return "No"");'
Challenge Seed
function testLogicalAnd(val) {
// Only change code below this line
if (val) {
if (val) {
return "Yes";
}
}
// Only change code above this line
return "No";
}
// Change this value to test
testLogicalAnd(10);
Solution
// solution required