&&
) true
إذا وفقط إذا كانت المعاملات إلى اليسار واليمين صحيحاً. يمكن تحقيق نفس التأثير بتضمين جملة if داخل أخرى إذا: if (num> 5) {سيعود فقط "نعم" إذا
إذا (عدد <10) {
العودة "نعم" ؛
}
}
العودة "لا" ؛
num
أكبر من 5
وأقل من 10
. نفس المنطق يمكن كتابته على النحو التالي: if (num> 5 & num <10) {
العودة "نعم" ؛
}
العودة "لا" ؛
"Yes"
إذا كان val
أقل من أو يساوي 50
وأكبر من أو يساوي 25
. خلاف ذلك ، سيعود "No"
. &&
مرة واحدة
testString: 'assert(code.match(/&&/g).length === 1, "You should use the &&
operator once");'
- text: يجب أن يكون لديك واحد فقط if
البيان
testString: 'assert(code.match(/if/g).length === 1, "You should only have one if
statement");'
- text: يجب أن ترجع testLogicalAnd(0)
"لا"
testString: 'assert(testLogicalAnd(0) === "No", "testLogicalAnd(0)
should return "No"");'
- text: testLogicalAnd(24)
يجب أن ترجع "لا"
testString: 'assert(testLogicalAnd(24) === "No", "testLogicalAnd(24)
should return "No"");'
- text: testLogicalAnd(25)
يجب أن ترجع "Yes"
testString: 'assert(testLogicalAnd(25) === "Yes", "testLogicalAnd(25)
should return "Yes"");'
- text: يجب أن ترجع testLogicalAnd(30)
"نعم"
testString: 'assert(testLogicalAnd(30) === "Yes", "testLogicalAnd(30)
should return "Yes"");'
- text: يجب أن ترجع testLogicalAnd(50)
"نعم"
testString: 'assert(testLogicalAnd(50) === "Yes", "testLogicalAnd(50)
should return "Yes"");'
- text: testLogicalAnd(51)
يجب أن ترجع "لا"
testString: 'assert(testLogicalAnd(51) === "No", "testLogicalAnd(51)
should return "No"");'
- text: يجب أن testLogicalAnd(75)
"لا"
testString: 'assert(testLogicalAnd(75) === "No", "testLogicalAnd(75)
should return "No"");'
- text: testLogicalAnd(80)
يجب أن ترجع "لا"
testString: 'assert(testLogicalAnd(80) === "No", "testLogicalAnd(80)
should return "No"");'
```