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

2.2 KiB

id, title, challengeType, videoUrl, forumTopicId, dashedName
id title challengeType videoUrl forumTopicId dashedName
56533eb9ac21ba0edf2244d8 Comparisons with the Logical And Operator 1 https://scrimba.com/c/cvbRVtr 16799 comparisons-with-the-logical-and-operator

--description--

Sometimes you will need to test more than one thing at a time. The logical and operator (&&) returns true if and only if the operands to the left and right of it are true.

The same effect could be achieved by nesting an if statement inside another if:

if (num > 5) {
  if (num < 10) {
    return "Yes";
  }
}
return "No";

will only return "Yes" if num is greater than 5 and less than 10. The same logic can be written as:

if (num > 5 && num < 10) {
  return "Yes";
}
return "No";

--instructions--

Replace the two if statements with one statement, using the && operator, which will return "Yes" if val is less than or equal to 50 and greater than or equal to 25. Otherwise, will return "No".

--hints--

You should use the && operator once

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

You should only have one if statement

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

testLogicalAnd(0) should return "No"

assert(testLogicalAnd(0) === 'No');

testLogicalAnd(24) should return "No"

assert(testLogicalAnd(24) === 'No');

testLogicalAnd(25) should return "Yes"

assert(testLogicalAnd(25) === 'Yes');

testLogicalAnd(30) should return "Yes"

assert(testLogicalAnd(30) === 'Yes');

testLogicalAnd(50) should return "Yes"

assert(testLogicalAnd(50) === 'Yes');

testLogicalAnd(51) should return "No"

assert(testLogicalAnd(51) === 'No');

testLogicalAnd(75) should return "No"

assert(testLogicalAnd(75) === 'No');

testLogicalAnd(80) should return "No"

assert(testLogicalAnd(80) === 'No');

--seed--

--seed-contents--

function testLogicalAnd(val) {
  // Only change code below this line

  if (val) {
    if (val) {
      return "Yes";
    }
  }

  // Only change code above this line
  return "No";
}

testLogicalAnd(10);

--solutions--

function testLogicalAnd(val) {
  if (val >= 25 && val <= 50) {
    return "Yes";
  }
  return "No";
}