fix(curriculum): tests passing with seed code in Statistic calculator (#55591)

This commit is contained in:
Krzysztof G. 2024-08-13 09:06:43 +02:00 committed by GitHub
parent 5a890998a4
commit e121fb6e28
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 15 additions and 5 deletions

View File

@ -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.

View File

@ -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--

View File

@ -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.

View File

@ -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.