chore(i8n,learn): processed translations

This commit is contained in:
Crowdin Bot
2021-02-06 04:42:36 +00:00
committed by Mrugesh Mohapatra
parent 15047f2d90
commit e5c44a3ae5
3274 changed files with 172122 additions and 14164 deletions

View File

@ -1,36 +1,48 @@
---
id: 594810f028c0303b75339ace
title: 蓄能器工厂
title: Accumulator factory
challengeType: 5
videoUrl: ''
forumTopicId: 302222
dashedName: accumulator-factory
---
# --description--
<p>创建一个带有单个(数字)参数的函数,并返回另一个作为累加器的函数。返回的累加器函数又接受一个数字参数,并返回到目前为止传递给该累加器的所有数值的总和(包括创建累加器时传递的初始值)。 </p><p>规则: </p><p>不要使用全局变量。 </p><p>暗示: </p><p>闭包可以保存外部状态。 </p>
A problem posed by [Paul Graham](https://en.wikipedia.org/wiki/Paul_Graham_(programmer)) is that of creating a function that takes a single (numeric) argument and which returns another function that is an accumulator. The returned accumulator function in turn also takes a single numeric argument, and returns the sum of all the numeric values passed in so far to that accumulator (including the initial value passed when the accumulator was created).
# --instructions--
Create a function that takes a number $n$ and generates accumulator functions that return the sum of every number ever passed to them.
**Rules:**
Do not use global variables.
**Hint:**
Closures save outer state.
# --hints--
`accumulator`是一个功能。
`accumulator` should be a function.
```js
assert(typeof accumulator === 'function');
```
`accumulator(0)`应该返回一个函数。
`accumulator(0)` should return a function.
```js
assert(typeof accumulator(0) === 'function');
```
`accumulator(0)(2)`应该返回一个数字。
`accumulator(0)(2)` should return a number.
```js
assert(typeof accumulator(0)(2) === 'number');
```
传递值3-4,1.5和5应返回5.5
Passing in the values 3, -4, 1.5, and 5 should return 5.5.
```js
assert(testFn(5) === 5.5);