mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-06-19 21:09:51 +08:00
fix(curriculum): no optional parenthesis for multi-parameter function (#53468)
This commit is contained in:
parent
51a5d6ef56
commit
78fd39a038
@ -28,13 +28,13 @@ assert.match(getVariance.toString(), /sumSquaredDifferences\s*=\s*squaredDiffere
|
||||
Your `sumSquaredDifferences` variable should use the `acc` and `el` parameters in the callback function.
|
||||
|
||||
```js
|
||||
assert.match(getVariance.toString(), /sumSquaredDifferences\s*=\s*squaredDifferences\.reduce\(function\s*\(?\s*acc\s*,\s*el\s*\)?/);
|
||||
assert.match(getVariance.toString(), /sumSquaredDifferences\s*=\s*squaredDifferences\.reduce\(function\s*\(\s*acc\s*,\s*el\s*\)/);
|
||||
```
|
||||
|
||||
Your `reduce` callback should return the sum of `acc` and `el`.
|
||||
|
||||
```js
|
||||
assert.match(getVariance.toString(), /sumSquaredDifferences\s*=\s*squaredDifferences\.reduce\(function\s*\(?\s*acc\s*,\s*el\s*\)?\s*\{\s*return\s*acc\s*\+\s*el\s*\;\s*\},\s*0\s*\)/);
|
||||
assert.match(getVariance.toString(), /sumSquaredDifferences\s*=\s*squaredDifferences\.reduce\(function\s*\(\s*acc\s*,\s*el\s*\)\s*\{\s*return\s*acc\s*\+\s*el\s*\;\s*\},\s*0\s*\)/);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
@ -46,19 +46,19 @@ assert.match(getVariance.toString(), /variance\s*=\s*array\.reduce\(/);
|
||||
Your `variance` variable should use the `acc` and `el` parameters in the callback function.
|
||||
|
||||
```js
|
||||
assert.match(getVariance.toString(), /variance\s*=\s*array\.reduce\(function\s*\(?\s*acc\s*,\s*el\s*\)?/);
|
||||
assert.match(getVariance.toString(), /variance\s*=\s*array\.reduce\(function\s*\(\s*acc\s*,\s*el\s*\)/);
|
||||
```
|
||||
|
||||
Your `reduce` callback should be an empty function.
|
||||
|
||||
```js
|
||||
assert.match(getVariance.toString(), /variance\s*=\s*array\.reduce\(function\s*\(?\s*acc\s*,\s*el\s*\)?\s*\{\s*\}/);
|
||||
assert.match(getVariance.toString(), /variance\s*=\s*array\.reduce\(function\s*\(\s*acc\s*,\s*el\s*\)\s*\{\s*\}/);
|
||||
```
|
||||
|
||||
Your `reduce` callback should have an initial value of `0`.
|
||||
|
||||
```js
|
||||
assert.match(getVariance.toString(), /variance\s*=\s*array\.reduce\(function\s*\(?\s*acc\s*,\s*el\s*\)?\s*\{\s*\}\s*,\s*0\s*\)/);
|
||||
assert.match(getVariance.toString(), /variance\s*=\s*array\.reduce\(function\s*\(\s*acc\s*,\s*el\s*\)\s*\{\s*\}\s*,\s*0\s*\)/);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
@ -14,37 +14,37 @@ Within your empty `.reduce()` callback, declare a variable `difference` and set
|
||||
Your `reduce` callback should have a `difference` variable.
|
||||
|
||||
```js
|
||||
assert.match(getVariance.toString(), /variance\s*=\s*array\.reduce\(function\s*\(?\s*acc\s*,\s*el\s*\)?\s*\{\s*var\s+difference\s*=/);
|
||||
assert.match(getVariance.toString(), /variance\s*=\s*array\.reduce\(function\s*\(\s*acc\s*,\s*el\s*\)\s*\{\s*var\s+difference\s*=/);
|
||||
```
|
||||
|
||||
Your `difference` variable should be set to the value of `el` minus `mean`.
|
||||
|
||||
```js
|
||||
assert.match(getVariance.toString(), /variance\s*=\s*array\.reduce\(function\s*\(?\s*acc\s*,\s*el\s*\)?\s*\{\s*var\s+difference\s*=\s*el\s*-\s*mean\s*;/);
|
||||
assert.match(getVariance.toString(), /variance\s*=\s*array\.reduce\(function\s*\(\s*acc\s*,\s*el\s*\)\s*\{\s*var\s+difference\s*=\s*el\s*-\s*mean\s*;/);
|
||||
```
|
||||
|
||||
Your `reduce` callback should have a `squared` variable.
|
||||
|
||||
```js
|
||||
assert.match(getVariance.toString(), /variance\s*=\s*array\.reduce\(function\s*\(?\s*acc\s*,\s*el\s*\)?\s*\{\s*var\s+difference\s*=\s*el\s*-\s*mean\s*;\s*var\s+squared\s*=/);
|
||||
assert.match(getVariance.toString(), /variance\s*=\s*array\.reduce\(function\s*\(\s*acc\s*,\s*el\s*\)\s*\{\s*var\s+difference\s*=\s*el\s*-\s*mean\s*;\s*var\s+squared\s*=/);
|
||||
```
|
||||
|
||||
Your `squared` variable should be set to the value of `difference` to the power of 2.
|
||||
|
||||
```js
|
||||
assert.match(getVariance.toString(), /variance\s*=\s*array\.reduce\(function\s*\(?\s*acc\s*,\s*el\s*\)?\s*\{\s*var\s+difference\s*=\s*el\s*-\s*mean\s*;\s*var\s+squared\s*=\s*Math\.pow\(\s*difference\s*,\s*2\s*\);/);
|
||||
assert.match(getVariance.toString(), /variance\s*=\s*array\.reduce\(function\s*\(\s*acc\s*,\s*el\s*\)\s*\{\s*var\s+difference\s*=\s*el\s*-\s*mean\s*;\s*var\s+squared\s*=\s*Math\.pow\(\s*difference\s*,\s*2\s*\);/);
|
||||
```
|
||||
|
||||
Your `reduce` callback should return the value of `acc` plus `squared`.
|
||||
|
||||
```js
|
||||
assert.match(getVariance.toString(), /variance\s*=\s*array\.reduce\(function\s*\(?\s*acc\s*,\s*el\s*\)?\s*\{\s*var\s+difference\s*=\s*el\s*-\s*mean\s*;\s*var\s+squared\s*=\s*Math\.pow\(\s*difference\s*,\s*2\s*\);\s*return\s+acc\s*\+\s*squared\s*;/);
|
||||
assert.match(getVariance.toString(), /variance\s*=\s*array\.reduce\(function\s*\(\s*acc\s*,\s*el\s*\)\s*\{\s*var\s+difference\s*=\s*el\s*-\s*mean\s*;\s*var\s+squared\s*=\s*Math\.pow\(\s*difference\s*,\s*2\s*\);\s*return\s+acc\s*\+\s*squared\s*;/);
|
||||
```
|
||||
|
||||
You should not remove the initial value of `0` from your `.reduce()` method.
|
||||
|
||||
```js
|
||||
assert.match(getVariance.toString(), /variance\s*=\s*array\.reduce\(function\s*\(?\s*acc\s*,\s*el\s*\)?\s*\{\s*var\s+difference\s*=\s*el\s*-\s*mean\s*;\s*var\s+squared\s*=\s*Math\.pow\(\s*difference\s*,\s*2\s*\);\s*return\s+acc\s*\+\s*squared\s*;\s*\}\s*,\s*0\)/);
|
||||
assert.match(getVariance.toString(), /variance\s*=\s*array\.reduce\(function\s*\(\s*acc\s*,\s*el\s*\)\s*\{\s*var\s+difference\s*=\s*el\s*-\s*mean\s*;\s*var\s+squared\s*=\s*Math\.pow\(\s*difference\s*,\s*2\s*\);\s*return\s+acc\s*\+\s*squared\s*;\s*\}\s*,\s*0\)/);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
@ -16,7 +16,7 @@ Divide your `.reduce()` call by the length of the array (in your `variance` decl
|
||||
You should divide the result of the `.reduce()` call by the length of the array.
|
||||
|
||||
```js
|
||||
assert.match(getVariance.toString(), /variance\s*=\s*array\.reduce\(function\s*\(?\s*acc\s*,\s*el\s*\)?\s*\{\s*var\s+difference\s*=\s*el\s*-\s*mean\s*;\s*var\s+squared\s*=\s*Math\.pow\(\s*difference\s*,\s*2\s*\);\s*return\s+acc\s*\+\s*squared\s*;\s*\}\s*,\s*0\)\s*\/\s*array\.length;/);
|
||||
assert.match(getVariance.toString(), /variance\s*=\s*array\.reduce\(function\s*\(\s*acc\s*,\s*el\s*\)\s*\{\s*var\s+difference\s*=\s*el\s*-\s*mean\s*;\s*var\s+squared\s*=\s*Math\.pow\(\s*difference\s*,\s*2\s*\);\s*return\s+acc\s*\+\s*squared\s*;\s*\}\s*,\s*0\)\s*\/\s*array\.length;/);
|
||||
```
|
||||
|
||||
You should return the value of `variance`.
|
||||
|
||||
Loading…
Reference in New Issue
Block a user