Oliver Eyton-Williams ee1e8abd87
feat(curriculum): restore seed + solution to Chinese (#40683)
* feat(tools): add seed/solution restore script

* chore(curriculum): remove empty sections' markers

* chore(curriculum): add seed + solution to Chinese

* chore: remove old formatter

* fix: update getChallenges

parse translated challenges separately, without reference to the source

* chore(curriculum): add dashedName to English

* chore(curriculum): add dashedName to Chinese

* refactor: remove unused challenge property 'name'

* fix: relax dashedName requirement

* fix: stray tag

Remove stray `pre` tag from challenge file.

Signed-off-by: nhcarrigan <nhcarrigan@gmail.com>

Co-authored-by: nhcarrigan <nhcarrigan@gmail.com>
2021-01-12 19:31:00 -07:00

1.7 KiB
Raw Blame History

id, title, challengeType, videoUrl, forumTopicId, dashedName
id title challengeType videoUrl forumTopicId dashedName
56533eb9ac21ba0edf2244da 介绍 else 语句 1 https://scrimba.com/c/cek4Efq 18207 introducing-else-statements

--description--

if语句的条件为真大括号里的代码执行那如果条件为假呢正常情况下什么也不会发生。使用else语句可以执行当条件为假时相应的代码。

if (num > 10) {
  return "Bigger than 10";
} else {
  return "10 or Less";
}

--instructions--

请把多个if语句合并为一个if/else语句。

--hints--

你应该只有一个if表达式。

assert(code.match(/if/g).length === 1);

你应该使用一个else表达式。

assert(/else/g.test(code));

testElse(4)应该返回 "5 or Smaller"。

assert(testElse(4) === '5 or Smaller');

testElse(5)应该返回 "5 or Smaller"。

assert(testElse(5) === '5 or Smaller');

testElse(6)应该返回 "Bigger than 5"。

assert(testElse(6) === 'Bigger than 5');

testElse(10)应该返回 "Bigger than 5"。

assert(testElse(10) === 'Bigger than 5');

不要修改上面和下面的代码。

assert(/var result = "";/.test(code) && /return result;/.test(code));

--seed--

--seed-contents--

function testElse(val) {
  var result = "";
  // Only change code below this line

  if (val > 5) {
    result = "Bigger than 5";
  }

  if (val <= 5) {
    result = "5 or Smaller";
  }

  // Only change code above this line
  return result;
}

testElse(4);

--solutions--

function testElse(val) {
  var result = "";
  if(val > 5) {
    result = "Bigger than 5";
  } else {
    result = "5 or Smaller";
  }
  return result;
}