diff --git a/README.md b/README.md index 76f4f0ded..fbb0bc525 100644 --- a/README.md +++ b/README.md @@ -32,8 +32,6 @@
View contents -* [`arrayMax`](#arraymax) -* [`arrayMin`](#arraymin) * [`chunk`](#chunk) * [`compact`](#compact) * [`countOccurrences`](#countoccurrences) @@ -142,8 +140,6 @@
View contents -* [`arrayAverage`](#arrayaverage) -* [`arraySum`](#arraysum) * [`clampNumber`](#clampnumber) * [`collatz`](#collatz) * [`digitize`](#digitize) @@ -255,6 +251,18 @@
+### _Uncategorized_ + +
+View contents + +* [`average`](#average) +* [`max`](#max) +* [`min`](#min) +* [`sum`](#sum) + +
+ ## Adapter ### call @@ -425,52 +433,6 @@ arrayMax([1, 2, 4]); // 4 ## Array -### arrayMax - -Returns the maximum value in an array. - -Use `Math.max()` combined with the spread operator (`...`) to get the maximum value in the array. - -```js -const arrayMax = arr => Math.max(...arr); -``` - -
-Examples - -```js -arrayMax([10, 1, 5]); // 10 -``` - -
- - -[⬆ Back to top](#table-of-contents) - - -### arrayMin - -Returns the minimum value in an array. - -Use `Math.min()` combined with the spread operator (`...`) to get the minimum value in the array. - -```js -const arrayMin = arr => Math.min(...arr); -``` - -
-Examples - -```js -arrayMin([10, 1, 5]); // 1 -``` - -
- - -[⬆ Back to top](#table-of-contents) - - ### chunk Chunks an array into smaller arrays of a specified size. @@ -2251,52 +2213,6 @@ negate(isOdd)(1); // false ## Math -### arrayAverage - -Returns the average of an array of numbers. - -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 arrayAverage = arr => arr.reduce((acc, val) => acc + val, 0) / arr.length; -``` - -
-Examples - -```js -arrayAverage([1, 2, 3]); // 2 -``` - -
- - -[⬆ Back to top](#table-of-contents) - - -### arraySum - -Returns the sum of an array of numbers. - -Use `Array.reduce()` to add each value to an accumulator, initialized with a value of `0`. - -```js -const arraySum = arr => arr.reduce((acc, val) => acc + val, 0); -``` - -
-Examples - -```js -arraySum([1, 2, 3, 4]); // 10 -``` - -
- - -[⬆ Back to top](#table-of-contents) - - ### clampNumber Clamps `num` within the inclusive range specified by the boundary values `a` and `b`. @@ -4158,6 +4074,72 @@ validateNumber('10'); // true [⬆ Back to top](#table-of-contents) +## _Uncategorized_ + +### average + +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; +``` + +```js +average([1, 2, 3]); // 2 +``` + +[⬆ back to top](#table-of-contents) + +### max + +Returns the maximum value out of two or more numbers/arrays. + +Use `Math.max()` combined with the spread operator (`...`) to get the maximum value in the array. + +```js + +const max = (...arr) => Math.max(...[].concat(...arr); +``` + +```js +max([10, 1, 5]); // 10 +``` + +[⬆ back to top](#table-of-contents) + +### min + +Returns the minimum value in an array. + +Use `Math.min()` combined with the spread operator (`...`) to get the minimum value in the array. + +```js +const min = arr => Math.min(...[].concat(...arr)); +``` + +```js +min([10, 1, 5]); // 1 +``` + +[⬆ back to top](#table-of-contents) + +### sum + +Returns the sum of an of two or more numbers/arrays. + +Use `Array.reduce()` to add each value to an accumulator, initialized with a value of `0`. + +```js +const sum = (...arr) => [].concat(...arr).reduce((acc, val) => acc + val, 0); +``` + +```js +sum([1, 2, 3, 4]); // 10 +``` + +[⬆ back to top](#table-of-contents) ## Credits diff --git a/docs/index.html b/docs/index.html index 46e60878d..004f9145a 100644 --- a/docs/index.html +++ b/docs/index.html @@ -107,9 +107,7 @@ spreadOver

Array -

arrayMax -arrayMin -chunk +chunk compact countOccurrences deepFlatten @@ -187,9 +185,7 @@ negate

Math -

arrayAverage -arraySum -clampNumber +clampNumber collatz digitize distance @@ -268,6 +264,12 @@ toOrdinalSuffix validateNumber +

Uncategorized +

average +max +min +sum +
 

Adapter

call

Given a key and a set of arguments, call them when given a context. Primarily useful in composition.

@@ -340,21 +342,7 @@ arrayMax([1, 2, 3]); // 3 arrayMax([1, 2, 4]); // 4

Array

-

arrayMax

-

Returns the maximum value in an array.

-

Use Math.max() combined with the spread operator (...) to get the maximum value in the array.

-
const arrayMax = arr => Math.max(...arr);
-
-
arrayMax([10, 1, 5]); // 10
-
-

arrayMin

-

Returns the minimum value in an array.

-

Use Math.min() combined with the spread operator (...) to get the minimum value in the array.

-
const arrayMin = arr => Math.min(...arr);
-
-
arrayMin([10, 1, 5]); // 1
-
-

chunk

+

chunk

Chunks an array into smaller arrays of a specified size.

Use Array.from() to create a new array, that fits the number of chunks that will be produced. Use Array.slice() to map each element of the new array to a chunk the length of size. @@ -1047,21 +1035,7 @@ runPromisesInSeries([() => delay(1000), () => delay(2000)]); // //executes negate(isOdd)(1); // false


Math

-

arrayAverage

-

Returns the average of an array of numbers.

-

Use Array.reduce() to add each value to an accumulator, initialized with a value of 0, divide by the length of the array.

-
const arrayAverage = arr => arr.reduce((acc, val) => acc + val, 0) / arr.length;
-
-
arrayAverage([1, 2, 3]); // 2
-
-

arraySum

-

Returns the sum of an array of numbers.

-

Use Array.reduce() to add each value to an accumulator, initialized with a value of 0.

-
const arraySum = arr => arr.reduce((acc, val) => acc + val, 0);
-
-
arraySum([1, 2, 3, 4]); // 10
-
-

clampNumber

+

clampNumber

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.

@@ -1836,6 +1810,36 @@ Use Number() to check if the coercion holds.

validateNumber('10'); // true
 
+

Uncategorized

+

average

+

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;
+
+
average([1, 2, 3]); // 2
+
+

max

+

Returns the maximum value out of two or more numbers/arrays.

+

Use Math.max() combined with the spread operator (...) to get the maximum value in the array.

+

+const max = (...arr) => Math.max(...[].concat(...arr);
+
+
max([10, 1, 5]); // 10
+
+

min

+

Returns the minimum value in an array.

+

Use Math.min() combined with the spread operator (...) to get the minimum value in the array.

+
const min = arr => Math.min(...[].concat(...arr));
+
+
min([10, 1, 5]); // 1
+
+

sum

+

Returns the sum of an of two or more numbers/arrays.

+

Use Array.reduce() to add each value to an accumulator, initialized with a value of 0.

+
const sum = (...arr) => [].concat(...arr).reduce((acc, val) => acc + val, 0);
+
+
sum([1, 2, 3, 4]); // 10
+