diff --git a/README.md b/README.md index c2fcc5b05..7248e3af0 100644 --- a/README.md +++ b/README.md @@ -173,9 +173,7 @@ * [`isEven`](#iseven) * [`isPrime`](#isprime) * [`lcm`](#lcm) -* [`max`](#max) * [`median`](#median) -* [`min`](#min) * [`percentile`](#percentile) * [`powerset`](#powerset) * [`primes`](#primes) @@ -3052,28 +3050,6 @@ lcm([1, 3, 4], 5); // 60
[⬆ 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)); -``` - -
-Examples - -```js -max([10, 1, 5]); // 10 -``` - -
- -
[⬆ Back to top](#table-of-contents) - - ### median Returns the median of an array of numbers. @@ -3102,28 +3078,6 @@ median([0, 10, -2, 7]); // 3.5
[⬆ 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)); -``` - -
-Examples - -```js -min([10, 1, 5]); // 1 -``` - -
- -
[⬆ Back to top](#table-of-contents) - - ### percentile Uses the percentile formula to calculate how many numbers in the given array are less or equal to the given value. diff --git a/docs/index.html b/docs/index.html index 6628f7b3b..8effda04f 100644 --- a/docs/index.html +++ b/docs/index.html @@ -59,7 +59,7 @@ wrapper.appendChild(box); box.appendChild(el); }); - }

 30 seconds of code Curated collection of useful JavaScript snippets that you can understand in 30 seconds or less.

 

Adapter

call

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

Use a closure to call a stored key with stored arguments.

const call = (key, ...args) => context => context[key](...args);
+    }

 30 seconds of code Curated collection of useful JavaScript snippets that you can understand in 30 seconds or less.

 

Adapter

call

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

Use a closure to call a stored key with stored arguments.

const call = (key, ...args) => context => context[key](...args);
 
Promise.resolve([1, 2, 3])
   .then(call('map', x => 2 * x))
   .then(console.log); //[ 2, 4, 6 ]
@@ -661,8 +661,6 @@ isPrime(12); // false
 };
 
lcm(12, 7); // 84
 lcm([1, 3, 4], 5); // 60
-

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
 

median

Returns the median of an array of numbers.

Find the middle of the array, use Array.sort() to sort the values. Return the number at the midpoint if length is odd, otherwise the average of the two middle numbers.

const median = arr => {
   const mid = Math.floor(arr.length / 2),
     nums = [...arr].sort((a, b) => a - b);
@@ -670,8 +668,6 @@ lcm([1, 3, 4], 5); // 60
 };
 
median([5, 6, 50, 1, -5]); // 5
 median([0, 10, -2, 7]); // 3.5
-

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
 

percentile

Uses the percentile formula to calculate how many numbers in the given array are less or equal to the given value.

Use Array.reduce() to calculate how many numbers are below the value and how many are the same value and apply the percentile formula.

const percentile = (arr, val) =>
   100 * arr.reduce((acc, v) => acc + (v < val ? 1 : 0) + (v === val ? 0.5 : 0), 0) / arr.length;
 
percentile([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], 6); // 55
diff --git a/tag_database b/tag_database
index 3c5423390..03d2e17ba 100644
--- a/tag_database
+++ b/tag_database
@@ -95,8 +95,10 @@ lcm:math
 lowercaseKeys:object
 mapObject:array
 mask:string
+maxN:uncategorized
 median:math
 memoize:function
+minN:uncategorized
 negate:logic
 nthElement:array
 objectFromPairs:object