diff --git a/README.md b/README.md
index 9b5bca310..1e379163e 100644
--- a/README.md
+++ b/README.md
@@ -2142,7 +2142,10 @@ Returns the average of an of two or more numbers/arrays.
Use `Array.reduce()` to add each value to an accumulator, initialized with a value of `0`, divide by the `length` of the array.
```js
-const average = (...arr) => [].concat(...arr).reduce((acc, val) => acc + val, 0) / arr.length;
+const average = (...arr) => {
+ const nums = [].concat(...arr);
+ return nums.reduce((acc, val) => acc + val, 0) / nums.length;
+};
```
Negates a predicate function.
Take a predicate function and apply not to it with its arguments.
const negate = func => (...args) => !func(...args);
filter([1, 2, 3, 4, 5, 6], negate(isEven)); // [1, 3, 5]
negate(isOdd)(1); // false
-Returns the average of an of two or more numbers/arrays.
Use Array.reduce() to add each value to an accumulator, initialized with a value of 0, divide by the length of the array.
const average = (...arr) => [].concat(...arr).reduce((acc, val) => acc + val, 0) / arr.length;
+Returns the average of an of two or more numbers/arrays.
Use Array.reduce() to add each value to an accumulator, initialized with a value of 0, divide by the length of the array.
const average = (...arr) => {
+ const nums = [].concat(...arr);
+ return nums.reduce((acc, val) => acc + val, 0) / nums.length;
+};
average([1, 2, 3]); // 2
+average(1, 2, 3); // 2
Clamps num within the inclusive range specified by the boundary values a and b.
If num falls within the range, return num. Otherwise, return the nearest number in the range.
const clampNumber = (num, a, b) => Math.max(Math.min(num, Math.max(a, b)), Math.min(a, b));
clampNumber(2, 3, 5); // 3
clampNumber(1, -1, -5); // -1