Oliver Eyton-Williams 61460c8601 fix: insert blank line after ```
search and replace ```\n< with ```\n\n< to ensure there's an empty line
before closing tags
2020-08-16 04:45:20 +05:30

1.8 KiB
Raw Blame History

id, title, isRequired, challengeType, videoUrl, localeTitle
id title isRequired challengeType videoUrl localeTitle
a97fd23d9b809dac9921074f Arguments Optional true 5 参数可选

Description

创建一个将两个参数相加的函数。如果只提供了一个参数,则返回一个需要一个参数并返回总和的函数。例如, addTogether(2, 3)应返回5 addTogether(2)应返回一个函数。使用单个参数调用此返回函数将返回总和: var sumTwoAnd = addTogether(2); sumTwoAnd(3)返回5 。如果任一参数不是有效数字则返回undefined。如果卡住请记得使用Read-Search-Ask 。尝试配对程序。编写自己的代码。

Instructions

Tests

tests:
  - text: '<code>addTogether(2, 3)</code>应该返回5。'
    testString: assert.deepEqual(addTogether(2, 3), 5);
  - text: <code>addTogether(2)(3)</code>应该返回5。
    testString: assert.deepEqual(addTogether(2)(3), 5);
  - text: '<code>addTogether(&quot;http://bit.ly/IqT6zt&quot;)</code>应返回undefined。'
    testString: assert.isUndefined(addTogether("http://bit.ly/IqT6zt"));
  - text: '<code>addTogether(2, &quot;3&quot;)</code>应返回undefined。'
    testString: assert.isUndefined(addTogether(2, "3"));
  - text: '<code>addTogether(2)([3])</code>应返回undefined。'
    testString: assert.isUndefined(addTogether(2)([3]));

Challenge Seed

function addTogether() {
  return false;
}

addTogether(2,3);

Solution

// solution required

/section>