64 lines
1.7 KiB
Markdown
64 lines
1.7 KiB
Markdown
|
---
|
||
|
id: a3566b1109230028080c9345
|
||
|
title: Sum All Numbers in a Range
|
||
|
isRequired: true
|
||
|
challengeType: 5
|
||
|
videoUrl: ''
|
||
|
localeTitle: 求和范围中的所有数字
|
||
|
---
|
||
|
|
||
|
## Description
|
||
|
<section id="description">我们将通过两个数字的数组。返回这两个数字的总和加上它们之间所有数字的总和。最低的数字并不总是第一位。如果卡住,请记得使用<a href="http://forum.freecodecamp.org/t/how-to-get-help-when-you-are-stuck/19514" target="_blank">Read-Search-Ask</a> 。尝试配对程序。编写自己的代码。 </section>
|
||
|
|
||
|
## Instructions
|
||
|
<section id="instructions">
|
||
|
</section>
|
||
|
|
||
|
## Tests
|
||
|
<section id='tests'>
|
||
|
|
||
|
```yml
|
||
|
tests:
|
||
|
- text: '<code>sumAll([1, 4])</code>应该返回一个数字。'
|
||
|
testString: 'assert(typeof sumAll([1, 4]) === "number", "<code>sumAll([1, 4])</code> should return a number.");'
|
||
|
- text: '<code>sumAll([1, 4])</code>应该返回10。'
|
||
|
testString: 'assert.deepEqual(sumAll([1, 4]), 10, "<code>sumAll([1, 4])</code> should return 10.");'
|
||
|
- text: '<code>sumAll([4, 1])</code>应该返回10。'
|
||
|
testString: 'assert.deepEqual(sumAll([4, 1]), 10, "<code>sumAll([4, 1])</code> should return 10.");'
|
||
|
- text: '<code>sumAll([5, 10])</code>应该返回45。'
|
||
|
testString: 'assert.deepEqual(sumAll([5, 10]), 45, "<code>sumAll([5, 10])</code> should return 45.");'
|
||
|
- text: '<code>sumAll([10, 5])</code>应该返回45。'
|
||
|
testString: 'assert.deepEqual(sumAll([10, 5]), 45, "<code>sumAll([10, 5])</code> should return 45.");'
|
||
|
|
||
|
```
|
||
|
|
||
|
</section>
|
||
|
|
||
|
## Challenge Seed
|
||
|
<section id='challengeSeed'>
|
||
|
|
||
|
<div id='js-seed'>
|
||
|
|
||
|
```js
|
||
|
function sumAll(arr) {
|
||
|
return 1;
|
||
|
}
|
||
|
|
||
|
sumAll([1, 4]);
|
||
|
|
||
|
```
|
||
|
|
||
|
</div>
|
||
|
|
||
|
|
||
|
|
||
|
</section>
|
||
|
|
||
|
## Solution
|
||
|
<section id='solution'>
|
||
|
|
||
|
```js
|
||
|
// solution required
|
||
|
```
|
||
|
</section>
|