* fix: Chinese test suite Add localeTiltes, descriptions, and adjust test text and testStrings to get the automated test suite working. * fix: ran script, updated testStrings and solutions
2.7 KiB
2.7 KiB
id, title, challengeType, videoUrl, localeTitle
id | title | challengeType | videoUrl | localeTitle |
---|---|---|---|---|
56533eb9ac21ba0edf2244d8 | Comparisons with the Logical And Operator | 1 | 与逻辑和运算符的比较 |
Description
true
时, 逻辑和运算符( &&
)才返回true。如果将if语句嵌套在另一个语句中,则可以实现相同的效果: if(num> 5){如果
if(num <10){
返回“是”;
}
}
返回“否”;
num
大于5
且小于10
则仅返回“Yes”。相同的逻辑可以写成: if(num> 5 && num <10){
返回“是”;
}
返回“否”;
Instructions
val
小于或等于50
且大于或等于25
,则返回"Yes"
。否则,将返回"No"
。 Tests
tests:
- text: 你应该使用一次<code>&&</code>运算符
testString: assert(code.match(/&&/g).length === 1);
- text: 你应该只有一个<code>if</code>语句
testString: assert(code.match(/if/g).length === 1);
- text: <code>testLogicalAnd(0)</code>应返回“否”
testString: assert(testLogicalAnd(0) === "No");
- text: <code>testLogicalAnd(24)</code>应返回“否”
testString: assert(testLogicalAnd(24) === "No");
- text: <code>testLogicalAnd(25)</code>应返回“是”
testString: assert(testLogicalAnd(25) === "Yes");
- text: <code>testLogicalAnd(30)</code>应该返回“是”
testString: assert(testLogicalAnd(30) === "Yes");
- text: <code>testLogicalAnd(50)</code>应该返回“是”
testString: assert(testLogicalAnd(50) === "Yes");
- text: <code>testLogicalAnd(51)</code>应返回“否”
testString: assert(testLogicalAnd(51) === "No");
- text: <code>testLogicalAnd(75)</code>应返回“否”
testString: assert(testLogicalAnd(75) === "No");
- text: <code>testLogicalAnd(80)</code>应返回“否”
testString: assert(testLogicalAnd(80) === "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