diff --git a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-advanced-array-methods-by-building-a-statistics-calculator/63507c19151201368ee3e16c.md b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-advanced-array-methods-by-building-a-statistics-calculator/63507c19151201368ee3e16c.md index 797f67b6d1c..19337fc5132 100644 --- a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-advanced-array-methods-by-building-a-statistics-calculator/63507c19151201368ee3e16c.md +++ b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-advanced-array-methods-by-building-a-statistics-calculator/63507c19151201368ee3e16c.md @@ -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. diff --git a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-advanced-array-methods-by-building-a-statistics-calculator/635085da54fc2041e0303e75.md b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-advanced-array-methods-by-building-a-statistics-calculator/635085da54fc2041e0303e75.md index 82e5ca1b9da..0b577d9356d 100644 --- a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-advanced-array-methods-by-building-a-statistics-calculator/635085da54fc2041e0303e75.md +++ b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-advanced-array-methods-by-building-a-statistics-calculator/635085da54fc2041e0303e75.md @@ -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-- diff --git a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-advanced-array-methods-by-building-a-statistics-calculator/63508750f040a348a440a0bf.md b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-advanced-array-methods-by-building-a-statistics-calculator/63508750f040a348a440a0bf.md index f2655fd1ba8..4c4425210fc 100644 --- a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-advanced-array-methods-by-building-a-statistics-calculator/63508750f040a348a440a0bf.md +++ b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-advanced-array-methods-by-building-a-statistics-calculator/63508750f040a348a440a0bf.md @@ -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. diff --git a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-advanced-array-methods-by-building-a-statistics-calculator/6352ea3a5b79e614ee2282fd.md b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-advanced-array-methods-by-building-a-statistics-calculator/6352ea3a5b79e614ee2282fd.md index 72b2cebe4fa..8c668a37b40 100644 --- a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-advanced-array-methods-by-building-a-statistics-calculator/6352ea3a5b79e614ee2282fd.md +++ b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-advanced-array-methods-by-building-a-statistics-calculator/6352ea3a5b79e614ee2282fd.md @@ -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.