--- id: 635085f80bd9b5429faa40c4 title: Step 15 challengeType: 0 dashedName: step-15 --- # --description-- You can actually clean this logic up a bit. Using the implicit return of an arrow function, you can directly return the value of the `.reduce()` method divided by the length of the array, without having to assign any variables. Update your `getMean` function as described above. # --hints-- You should remove the `sum` variable declaration. ```js assert.notMatch(getMean.toString(), /sum\s*=/); ``` You should remove the `mean` variable declaration. ```js assert.notMatch(getMean.toString(), /mean\s*=/); ``` You should not change the logic within the `reduce` method. ```js assert.match(getMean.toString(), /(array\.reduce\(\s*\(\s*acc\s*,\s*el\s*\)\s*=>|array\.reduce\(\s*function\s*\(\s*acc\s*,\s*el\s*\)\s*\{)\s*(return\s+)?\s*acc\s*\+\s*el\s*;?\s*\}?\s*,\s*0\s*\)/) ``` You should divide the result of the `reduce` method by the length of the array. ```js assert.match(getMean.toString(), /(array\.reduce\(\s*\(\s*acc\s*,\s*el\s*\)\s*=>|array\.reduce\(\s*function\s*\(\s*acc\s*,\s*el\s*\)\s*\{)\s*(return\s+)?\s*acc\s*\+\s*el\s*;?\s*\}?\s*,\s*0\s*\)\s*\/\s*array\.length/) ``` You should use implicit return syntax to directly return the result of `reduce` divided by the array length. ```js assert.match(code, /const\s+getMean\s*=\s*(\(\s*array\s*\)|array)\s*=>\s*array\.reduce\(\s*\(\s*acc\s*,\s*el\s*\)\s*=>\s*acc\s*\+\s*el\s*,\s*0\s*\)\s*\/\s*array\.length/) ``` # --seed-- ## --seed-contents-- ```html Statistics Calculator

Statistics Calculator

Enter a list of comma-separated numbers.

The mean of a list of numbers is the average, calculated by taking the sum of all numbers and dividing that by the count of numbers.

Mean:

The median of a list of numbers is the number that appears in the middle of the list, when sorted from least to greatest.

Median:

The mode of a list of numbers is the number that appears most often in the list.

Mode:

The range of a list of numbers is the difference between the largest and smallest numbers in the list.

Range:

The variance of a list of numbers measures how far the values are from the mean, on average.

Variance:

The standard deviation of a list of numbers is the square root of the variance.

Standard Deviation:

``` ```css body { margin: 0; background-color: rgb(27, 27, 50); text-align: center; color: #fff; } button { cursor: pointer; background-color: rgb(59, 59, 79); border: 3px solid white; color: white; } input { background-color: rgb(10, 10, 35); color: white; border: 1px solid rgb(59, 59, 79); } .bold { font-weight: bold; } ``` ```js --fcc-editable-region-- const getMean = (array) => { const sum = array.reduce((acc, el) => acc + el, 0); const mean = sum / array.length; return mean; } --fcc-editable-region-- const calculate = () => { const value = document.querySelector("#numbers").value; const array = value.split(/,\s*/g); const numbers = array.map(el => Number(el)).filter(el => !isNaN(el)); } ```