&&
) devuelven true
si y solo si los operandos a su izquierda y derecha son verdaderos. El mismo efecto podría lograrse anidando una instrucción if dentro de otra si: if (num> 5) {solo devolverá "Sí" si
si (num <10) {
devuelve "Sí";
}
}
devuelve "No";
num
es mayor que 5
y menor que 10
. La misma lógica se puede escribir como: if (num> 5 && num <10) {
devuelve "Sí";
}
devuelve "No";
"Yes"
si val
es menor o igual a 50
y mayor o igual a 25
. De lo contrario, devolverá "No"
. &&
una vez
testString: 'assert(code.match(/&&/g).length === 1, "You should use the &&
operator once");'
- text: Sólo debe tener una declaración if
testString: 'assert(code.match(/if/g).length === 1, "You should only have one if
statement");'
- text: testLogicalAnd(0)
debe devolver "No"
testString: 'assert(testLogicalAnd(0) === "No", "testLogicalAnd(0)
should return "No"");'
- text: testLogicalAnd(24)
debe devolver "No"
testString: 'assert(testLogicalAnd(24) === "No", "testLogicalAnd(24)
should return "No"");'
- text: testLogicalAnd(25)
debe devolver "Sí"
testString: 'assert(testLogicalAnd(25) === "Yes", "testLogicalAnd(25)
should return "Yes"");'
- text: testLogicalAnd(30)
debe devolver "Sí"
testString: 'assert(testLogicalAnd(30) === "Yes", "testLogicalAnd(30)
should return "Yes"");'
- text: testLogicalAnd(50)
debe devolver "Sí"
testString: 'assert(testLogicalAnd(50) === "Yes", "testLogicalAnd(50)
should return "Yes"");'
- text: testLogicalAnd(51)
debe devolver "No"
testString: 'assert(testLogicalAnd(51) === "No", "testLogicalAnd(51)
should return "No"");'
- text: testLogicalAnd(75)
debe devolver "No"
testString: 'assert(testLogicalAnd(75) === "No", "testLogicalAnd(75)
should return "No"");'
- text: testLogicalAnd(80)
debe devolver "No"
testString: 'assert(testLogicalAnd(80) === "No", "testLogicalAnd(80)
should return "No"");'
```