Travis build: 908
This commit is contained in:
95
README.md
95
README.md
@ -173,7 +173,9 @@
|
|||||||
* [`isEven`](#iseven)
|
* [`isEven`](#iseven)
|
||||||
* [`isPrime`](#isprime)
|
* [`isPrime`](#isprime)
|
||||||
* [`lcm`](#lcm)
|
* [`lcm`](#lcm)
|
||||||
|
* [`maxN`](#maxn)
|
||||||
* [`median`](#median)
|
* [`median`](#median)
|
||||||
|
* [`minN`](#minn)
|
||||||
* [`percentile`](#percentile)
|
* [`percentile`](#percentile)
|
||||||
* [`powerset`](#powerset)
|
* [`powerset`](#powerset)
|
||||||
* [`primes`](#primes)
|
* [`primes`](#primes)
|
||||||
@ -288,8 +290,7 @@
|
|||||||
<details>
|
<details>
|
||||||
<summary>View contents</summary>
|
<summary>View contents</summary>
|
||||||
|
|
||||||
* [`maxN`](#maxn)
|
* [`geometricProgression`](#geometricprogression)
|
||||||
* [`minN`](#minn)
|
|
||||||
|
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
@ -3050,6 +3051,31 @@ lcm([1, 3, 4], 5); // 60
|
|||||||
<br>[⬆ Back to top](#table-of-contents)
|
<br>[⬆ Back to top](#table-of-contents)
|
||||||
|
|
||||||
|
|
||||||
|
### maxN
|
||||||
|
|
||||||
|
Returns the `n` maximum elements from the provided array. If `n` is greater than or equal to the provided array's length than return the original array(sorted in descending order).
|
||||||
|
|
||||||
|
Sort's the array's shallow copy in descending order and returns the first n elements
|
||||||
|
|
||||||
|
Skip the second argument to get a single element(in the form of a array)
|
||||||
|
```js
|
||||||
|
const maxN = (arr, n = 1) => [...arr].sort((a, b) => b - a).slice(0, n);
|
||||||
|
```
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>Examples</summary>
|
||||||
|
|
||||||
|
```js
|
||||||
|
maxN([1, 2, 3]); // [3]
|
||||||
|
maxN([1, 2, 3], 2); // [3,2]
|
||||||
|
maxN([1, 2, 3], 4); // [3,2,1]
|
||||||
|
```
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
|
<br>[⬆ Back to top](#table-of-contents)
|
||||||
|
|
||||||
|
|
||||||
### median
|
### median
|
||||||
|
|
||||||
Returns the median of an array of numbers.
|
Returns the median of an array of numbers.
|
||||||
@ -3078,6 +3104,30 @@ median([0, 10, -2, 7]); // 3.5
|
|||||||
<br>[⬆ Back to top](#table-of-contents)
|
<br>[⬆ Back to top](#table-of-contents)
|
||||||
|
|
||||||
|
|
||||||
|
### minN
|
||||||
|
|
||||||
|
Returns the `n` minimum elements from the provided array. If `n` is greater than or equal to the provided array's length than return the original array(sorted in ascending order).
|
||||||
|
|
||||||
|
Sort's the array's shallow copy in ascending order and returns the first n elements
|
||||||
|
|
||||||
|
Skip the second argument to get a single element(in the form of a array)
|
||||||
|
```js
|
||||||
|
const minN = (arr, n = 1) => [...arr].sort((a, b) => a - b).slice(0, n);
|
||||||
|
```
|
||||||
|
<details>
|
||||||
|
<summary>Examples</summary>
|
||||||
|
|
||||||
|
```js
|
||||||
|
minN([1, 2, 3]); // [1]
|
||||||
|
minN([1, 2, 3], 2); // [1,2]
|
||||||
|
minN([1, 2, 3], 4); // [1,2,3]
|
||||||
|
```
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
|
<br>[⬆ Back to top](#table-of-contents)
|
||||||
|
|
||||||
|
|
||||||
### percentile
|
### percentile
|
||||||
|
|
||||||
Uses the percentile formula to calculate how many numbers in the given array are less or equal to the given value.
|
Uses the percentile formula to calculate how many numbers in the given array are less or equal to the given value.
|
||||||
@ -5098,40 +5148,27 @@ yesNo('Foo', true); // true
|
|||||||
---
|
---
|
||||||
## _Uncategorized_
|
## _Uncategorized_
|
||||||
|
|
||||||
### maxN
|
### geometricProgression
|
||||||
|
|
||||||
Returns the `n` maximum elements from the provided array. If `n` is greater than or equal to the provided array's length than return the original array(sorted in descending order).
|
Initializes an array containing the numbers in the specified range where `start` and `end` are inclusive and the ratio between two terms is `step`.
|
||||||
|
Returns an error if `step` equals `1`.
|
||||||
|
|
||||||
Sort's the array's shallow copy in descending order and returns the first n elements
|
Use `Array.from()`, `Math.log()` and `Math.floor()` to create an array of the desired length, `Array.map()` to fill with the desired values in a range.
|
||||||
|
Omit the second argument, `start`, to use a default value of `1`.
|
||||||
|
Omit the third argument, `step`, to use a default value of `2`.
|
||||||
|
|
||||||
Skip the second argument to get a single element(in the form of a array)
|
|
||||||
```js
|
```js
|
||||||
const maxN = (arr, n = 1) => [...arr].sort((a, b) => b - a).slice(0, n);
|
const geometricProgression = (end, start = 1, step = 2) =>
|
||||||
|
Array.from({ length: Math.floor(Math.log(end / start) / Math.log(step)) + 1 }).map(
|
||||||
|
(v, i) => start * step ** i
|
||||||
|
);
|
||||||
```
|
```
|
||||||
|
|
||||||
```js
|
```js
|
||||||
maxN([1, 2, 3]); // [3]
|
geometricProgression(256); // [1, 2, 4, 8, 16, 32, 64, 128, 256]
|
||||||
maxN([1, 2, 3], 2); // [3,2]
|
geometricProgression(256, 3); //[3, 6, 12, 24, 48, 96, 192]
|
||||||
maxN([1, 2, 3], 4); // [3,2,1]
|
geometricProgression(256, 1, 4); //[1, 4, 16, 64, 256]
|
||||||
```
|
geometricProgression(256, 2, 1); //Gives error
|
||||||
|
|
||||||
<br>[⬆ back to top](#table-of-contents)
|
|
||||||
|
|
||||||
|
|
||||||
### minN
|
|
||||||
|
|
||||||
Returns the `n` minimum elements from the provided array. If `n` is greater than or equal to the provided array's length than return the original array(sorted in ascending order).
|
|
||||||
|
|
||||||
Sort's the array's shallow copy in ascending order and returns the first n elements
|
|
||||||
|
|
||||||
Skip the second argument to get a single element(in the form of a array)
|
|
||||||
```js
|
|
||||||
const minN = (arr, n = 1) => [...arr].sort((a, b) => a - b).slice(0, n);
|
|
||||||
```
|
|
||||||
```js
|
|
||||||
minN([1, 2, 3]); // [1]
|
|
||||||
minN([1, 2, 3], 2); // [1,2]
|
|
||||||
minN([1, 2, 3], 4); // [1,2,3]
|
|
||||||
```
|
```
|
||||||
|
|
||||||
<br>[⬆ back to top](#table-of-contents)
|
<br>[⬆ back to top](#table-of-contents)
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@ -7,14 +7,16 @@ Use `Array.from()`, `Math.log()` and `Math.floor()` to create an array of the de
|
|||||||
Omit the second argument, `start`, to use a default value of `1`.
|
Omit the second argument, `start`, to use a default value of `1`.
|
||||||
Omit the third argument, `step`, to use a default value of `2`.
|
Omit the third argument, `step`, to use a default value of `2`.
|
||||||
|
|
||||||
``` js
|
```js
|
||||||
const geometricProgression = (end, start = 1,step = 2) =>
|
const geometricProgression = (end, start = 1, step = 2) =>
|
||||||
Array.from({ length:Math.floor(Math.log(end/start)/Math.log(step))+1}).map((v, i) => start * (step ** (i)) )
|
Array.from({ length: Math.floor(Math.log(end / start) / Math.log(step)) + 1 }).map(
|
||||||
|
(v, i) => start * step ** i
|
||||||
|
);
|
||||||
```
|
```
|
||||||
|
|
||||||
```js
|
```js
|
||||||
geometricProgression(256); // [1, 2, 4, 8, 16, 32, 64, 128, 256]
|
geometricProgression(256); // [1, 2, 4, 8, 16, 32, 64, 128, 256]
|
||||||
geometricProgression(256,3); //[3, 6, 12, 24, 48, 96, 192]
|
geometricProgression(256, 3); //[3, 6, 12, 24, 48, 96, 192]
|
||||||
geometricProgression(256,1,4); //[1, 4, 16, 64, 256]
|
geometricProgression(256, 1, 4); //[1, 4, 16, 64, 256]
|
||||||
geometricProgression(256,2,1); //Gives error
|
geometricProgression(256, 2, 1); //Gives error
|
||||||
```
|
```
|
||||||
|
|||||||
@ -49,6 +49,7 @@ flip:adapter
|
|||||||
fromCamelCase:string
|
fromCamelCase:string
|
||||||
functionName:function
|
functionName:function
|
||||||
gcd:math
|
gcd:math
|
||||||
|
geometricProgression:uncategorized
|
||||||
getDaysDiffBetweenDates:date
|
getDaysDiffBetweenDates:date
|
||||||
getScrollPosition:browser
|
getScrollPosition:browser
|
||||||
getStyle:browser
|
getStyle:browser
|
||||||
|
|||||||
Reference in New Issue
Block a user