chore(i18n,curriculum): update translations (#43089)
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 594810f028c0303b75339ace
|
||||
title: Accumulator factory
|
||||
title: Fábrica de acumuladores
|
||||
challengeType: 5
|
||||
forumTopicId: 302222
|
||||
dashedName: accumulator-factory
|
||||
@ -8,41 +8,41 @@ dashedName: accumulator-factory
|
||||
|
||||
# --description--
|
||||
|
||||
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).
|
||||
Um problema proposto por [Paul Graham](https://en.wikipedia.org/wiki/Paul_Graham_(programmer)) é o de criar uma função que recebe um único argumento (numérico) e que retorna outra função que é um acumulador. A função de acumulador retornada, por sua vez, também recebe um único argumento numérico e retorna a soma de todos os valores numéricos passados até aquele momento para esse acumulador (incluindo o valor inicial passado quando o acumulador foi criado).
|
||||
|
||||
# --instructions--
|
||||
|
||||
Create a function that takes a number $n$ and generates accumulator functions that return the sum of every number ever passed to them.
|
||||
Crie uma função que receba um número $n$ e gere funções acumuladoras que retornam a soma de cada número já passado para elas.
|
||||
|
||||
**Rules:**
|
||||
**Regras:**
|
||||
|
||||
Do not use global variables.
|
||||
Não use variáveis globais.
|
||||
|
||||
**Hint:**
|
||||
**Dica:**
|
||||
|
||||
Closures save outer state.
|
||||
Closures salvam o estado externo.
|
||||
|
||||
# --hints--
|
||||
|
||||
`accumulator` should be a function.
|
||||
`accumulator` deve ser uma função.
|
||||
|
||||
```js
|
||||
assert(typeof accumulator === 'function');
|
||||
```
|
||||
|
||||
`accumulator(0)` should return a function.
|
||||
`accumulator(0)` deve retornar uma função.
|
||||
|
||||
```js
|
||||
assert(typeof accumulator(0) === 'function');
|
||||
```
|
||||
|
||||
`accumulator(0)(2)` should return a number.
|
||||
`accumulator(0)(2)` deve retornar um número.
|
||||
|
||||
```js
|
||||
assert(typeof accumulator(0)(2) === 'number');
|
||||
```
|
||||
|
||||
Passing in the values 3, -4, 1.5, and 5 should return 5.5.
|
||||
Ao passar os valores 3, -4, 1.5 e 5, o valor retornado deve ser 5.5.
|
||||
|
||||
```js
|
||||
assert(testFn(5) === 5.5);
|
||||
|
Reference in New Issue
Block a user