mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-05-28 18:26:54 +00:00
fix(curriculum): Statistics Calculator make anonymous callback function optional (#55466)
Co-authored-by: Lasse Jørgensen <28780271+lasjorg@users.noreply.github.com>
This commit is contained in:
+5
-5
@@ -21,16 +21,16 @@ Add a callback function to your `.map()` method that converts each element to a
|
||||
|
||||
# --hints--
|
||||
|
||||
Your `.map()` method should have a callback function which takes an `el` parameter.
|
||||
Your `.map()` method should have a callback function.
|
||||
|
||||
```js
|
||||
assert.match(calculate.toString(), /array\.map\(\s*(\(\s*el\s*\)|el)\s*=>|array\.map\(\s*function\s*\(\s*el\s*\)\s*\{/)
|
||||
assert.match(calculate.toString(), /array\.map\(\s*(\(\s*\w+\s*\)|\w+)\s*=>|array\.map\(\s*function\s*\(\s*\w+\s*\)\s*\{|array\.map\(\s*Number\s*\)/)
|
||||
```
|
||||
|
||||
Your callback function should use the `Number` constructor to convert `el` to a number.
|
||||
Your callback function should use the `Number` constructor to convert each array element to a number.
|
||||
|
||||
```js
|
||||
assert.match(calculate.toString(), /Number\(\s*el\s*\)/);
|
||||
assert.match(calculate.toString(), /Number\(\s*\w+\s*\)|Number/);
|
||||
```
|
||||
|
||||
Your callback function should not use the `new` keyword with the `Number` constructor.
|
||||
@@ -42,7 +42,7 @@ assert.notMatch(calculate.toString(), /new/);
|
||||
Your callback function should return the element converted to a number.
|
||||
|
||||
```js
|
||||
assert.match(calculate.toString(), /(array\.map\(\s*(\(\s*el\s*\)|el)\s*=>|array\.map\(\s*function\s*\(\s*el\s*\)\s*\{)\s*(return\s+)?Number\(\s*el\s*\)/);
|
||||
assert.match(calculate.toString(), /(array\.map\(\s*(\(\s*\w+\s*\)|\w+)\s*=>|array\.map\(\s*function\s*\(\s*\w+\s*\)\s*\{)\s*(return\s+)?Number\(\s*\w+\s*\)|array\.map\(\s*Number\s*\)/);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
Reference in New Issue
Block a user