Use explicit default value

This commit is contained in:
atomiks
2017-12-14 20:24:07 +11:00
committed by GitHub
parent 98f56cbf23
commit bede528c52

View File

@ -6,7 +6,7 @@ of the values to determine the standard deviation of an array of numbers.
Since there are two types of standard deviation, population and sample, you can use a flag to switch to population (sample is default).
```js
const standardDeviation = (arr, usePopulation) => {
const standardDeviation = (arr, usePopulation = false) => {
const mean = arr.reduce((acc, val) => acc + val, 0) / arr.length;
return Math.sqrt(
arr.reduce((acc, val) => acc.concat(Math.pow(val - mean, 2)), [])