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

2.0 KiB
Raw Blame History

id, title, challengeType, videoUrl, localeTitle
id title challengeType videoUrl localeTitle
5690307fddb111c6084545d7 Logical Order in If Else Statements 1 如果其他陈述中的逻辑顺序

Description

订单在if else if语句中很重要。该函数从上到下执行,因此您需要注意首先出现的语句。以这两个函数为例。这是第一个:
function foox{
ifx <1{
返回“少于一个”;
} else ifx <2{
返回“少于两个”;
} else {
返回“大于或等于2”;
}
}
第二个只是切换语句的顺序:
功能栏x{
ifx <2{
返回“少于两个”;
} else ifx <1{
返回“少于一个”;
} else {
返回“大于或等于2”;
}
}
虽然如果我们将数字传递给两者,这两个函数看起来几乎相同但我们得到不同的输出。
foo0//“不到一个”
bar0//“少于两个”

Instructions

更改函数中的逻辑顺序,以便在所有情况下都返回正确的语句。

Tests

tests:
  - text: <code>orderMyLogic(4)</code>应返回“小于5”
    testString: assert(orderMyLogic(4) === "Less than 5");
  - text: <code>orderMyLogic(6)</code>应该返回“少于10”
    testString: assert(orderMyLogic(6) === "Less than 10");
  - text: <code>orderMyLogic(11)</code>应该返回“大于或等于10”
    testString: assert(orderMyLogic(11) === "Greater than or equal to 10");

Challenge Seed

function orderMyLogic(val) {
  if (val < 10) {
    return "Less than 10";
  } else if (val < 5) {
    return "Less than 5";
  } else {
    return "Greater than or equal to 10";
  }
}

// Change this value to test
orderMyLogic(7);

Solution

// solution required