mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-06-13 21:02:08 +08:00
fix(curriculum): tests passing with seed code in Statistic calculator (#55591)
This commit is contained in:
parent
5a890998a4
commit
e121fb6e28
@ -16,7 +16,7 @@ Create a `numbers` variable and assign it the value of `array.map()`. Remember t
|
||||
Your `calculate` function should have a `numbers` variable.
|
||||
|
||||
```js
|
||||
assert.match(calculate.toString(), /numbers/);
|
||||
assert.match(calculate.toString(), /(let|const|var)\s+numbers/);
|
||||
```
|
||||
|
||||
You should use the `.map()` method on your `array` variable.
|
||||
|
||||
@ -14,13 +14,22 @@ Finally, you need to return the value of `mean`.
|
||||
Your `getMean` function should use the `return` keyword.
|
||||
|
||||
```js
|
||||
assert.match(getMean.toString(), /return/);
|
||||
const functionContents = code.split(/const\s+getMean\s*=\s*/)?.[1]?.split(/\}/)?.[0];
|
||||
assert.match(functionContents, /return/);
|
||||
```
|
||||
|
||||
Your `getMean` function should return the value of `mean`.
|
||||
|
||||
```js
|
||||
assert.match(getMean.toString(), /return\s+mean\s*/);
|
||||
const functionContents = code.split(/const\s+getMean\s*=\s*/)?.[1]?.split(/\}/)?.[0];
|
||||
assert.match(functionContents, /return\s+mean/);
|
||||
```
|
||||
|
||||
Your `return` statement should be after the `mean` variable declaration.
|
||||
|
||||
```js
|
||||
const functionContents = code.split(/const\s+getMean\s*=\s*/)?.[1]?.split(/\}/)?.[0];
|
||||
assert.match(functionContents, /const\s+mean\s*=\s*sum\s*\/\s*array\.length\s*;?\s*return\s+mean/);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
@ -16,7 +16,7 @@ Use a `.querySelector` to find that element, and then set its `.textContent` to
|
||||
Your `calculate` function should use a `document.querySelector()`.
|
||||
|
||||
```js
|
||||
assert.match(calculate.toString(), /document\.querySelector\(/);
|
||||
assert.lengthOf(calculate.toString().match(/document\.querySelector\(/g), 2);
|
||||
```
|
||||
|
||||
Your `.querySelector()` should target the `#mean` element.
|
||||
|
||||
@ -18,7 +18,8 @@ Start by creating an `if` statement. In the condition, create a `Set` with `new
|
||||
Your `getMode` function should have an `if` statement.
|
||||
|
||||
```js
|
||||
assert.match(getMode.toString(), /if\s*\(/);
|
||||
const functionContents = code.split(/const\s+getMode\s*=\s*/)?.[1]?.split(/[^{]\}[^;)]/)?.[0];
|
||||
assert.match(functionContents, /if\s*\(/);
|
||||
```
|
||||
|
||||
Your `if` statement should create a new `Set` and pass the `Object.values()` of your `counts` object.
|
||||
|
||||
Loading…
Reference in New Issue
Block a user