Kristofer Koishigawa b3213fc892 fix(i18n): chinese test suite (#38220)
* 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
2020-03-03 18:49:47 +05:30

1.7 KiB
Raw Blame History

id, title, challengeType, videoUrl, localeTitle
id title challengeType videoUrl localeTitle
587d7b7e367417b2b2512b24 Use the Conditional (Ternary) Operator 1 使用条件(三元)运算符

Description

条件运算符 (也称为三元运算符 可以用作一行if-else表达式。语法是 condition ? statement-if-true : statement-if-false;以下函数使用if-else语句来检查条件
function findGreaterab{
ifa> b{
返回“a更大”;
}
其他{
返回“b更大”;
}
}
这可以使用conditional operator重写:
function findGreaterab{
返回a> b “a更大”“b更大”;
}

Instructions

checkEqual函数中使用conditional operator来检查两个数字是否相等。该函数应返回true或false。

Tests

tests:
  - text: <code>checkEqual</code>应该使用<code>conditional operator</code>
    testString: assert(/.+?\s*?\?\s*?.+?\s*?:\s*?.+?/.test(code));
  - text: '<code>checkEqual(1, 2)</code>应该返回false'
    testString: assert(checkEqual(1, 2) === "Not Equal");
  - text: '<code>checkEqual(1, 1)</code>应该返回true'
    testString: assert(checkEqual(1, 1) === "Equal");
  - text: '<code>checkEqual(1, -1)</code>应该返回false'
    testString: assert(checkEqual(1, -1) === "Not Equal");

Challenge Seed

function checkEqual(a, b) {

}

checkEqual(1, 2);

Solution

// solution required