65 lines
1.5 KiB
Markdown
Raw Normal View History

---
id: a3566b1109230028080c9345
title: Sum All Numbers in a Range
isRequired: true
challengeType: 5
videoUrl: ''
localeTitle: 求和范围中的所有数字
---
## Description
2020-06-30 01:51:26 -07:00
<section id="description">我们将通过两个数字的数组。返回这两个数字的总和加上它们之间所有数字的总和。最低的数字并不总是第一位。如果卡住,请记得使用<a href="https://forum.freecodecamp.org/t/how-to-get-help-when-you-are-stuck-coding/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');
- text: '<code>sumAll([1, 4])</code>应该返回10。'
testString: assert.deepEqual(sumAll([1, 4]), 10);
- text: '<code>sumAll([4, 1])</code>应该返回10。'
testString: assert.deepEqual(sumAll([4, 1]), 10);
- text: '<code>sumAll([5, 10])</code>应该返回45。'
testString: assert.deepEqual(sumAll([5, 10]), 45);
- text: '<code>sumAll([10, 5])</code>应该返回45。'
testString: assert.deepEqual(sumAll([10, 5]), 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>