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.9 KiB
Raw Blame History

id, title, challengeType, videoUrl, localeTitle
id title challengeType videoUrl localeTitle
587d7b7e367417b2b2512b21 Use Multiple Conditional (Ternary) Operators 1 使用多个条件(三元)运算符

Description

在之前的挑战中,您使用了单个conditional operator 。您也可以将它们链接在一起以检查多种条件。以下函数使用ifelse if和else语句来检查多个条件
function findGreaterOrEqualab{
ifa === b{
返回“a和b相等”;
}
否则如果a> b{
返回“a更大”;
}
其他{
返回“b更大”;
}
}
可以使用多个conditional operators重写上述函数:
function findGreaterOrEqualab{
返回a === b “a和b相等”a> b “a更大”“b更大”;
}

Instructions

checkSign函数中使用多个conditional operators来检查数字是正数,负数还是零。

Tests

tests:
  - text: <code>checkSign</code>应该使用多个<code>conditional operators</code>
    testString: assert(/.+?\s*?\?\s*?.+?\s*?:\s*?.+?\s*?\?\s*?.+?\s*?:\s*?.+?/gi.test(code));
  - text: <code>checkSign(10)</code>应该返回“positive”。请注意资本化很重要
    testString: assert(checkSign(10) === 'positive');
  - text: <code>checkSign(-12)</code>应返回“否定”。请注意,资本化很重要
    testString: assert(checkSign(-12) === 'negative');
  - text: <code>checkSign(0)</code>应返回“零”。请注意,资本化很重要
    testString: assert(checkSign(0) === 'zero');

Challenge Seed

function checkSign(num) {

}

checkSign(10);

Solution

// solution required