Travis build: 870

This commit is contained in:
30secondsofcode
2018-12-07 16:28:14 +00:00
parent b68365330a
commit b65d482dcf
18 changed files with 51 additions and 19 deletions

View File

@ -314,6 +314,7 @@ _30s.average(1, 2, 3);
* [`luhnCheck`](#luhncheck-)
* [`maxBy`](#maxby)
* [`median`](#median)
* [`midpoint`](#midpoint)
* [`minBy`](#minby)
* [`percentile`](#percentile)
* [`powerset`](#powerset)
@ -1254,14 +1255,14 @@ Filters out the falsy values in an array.
Use `Array.prototype.filter()` to get an array containing only truthy values.
```js
const filterFalsy = arr => arr.filter(Boolean);
const filterFalsy = arr => arr.filter(Boolean);
```
<details>
<summary>Examples</summary>
```js
filterFalsy(['', true, {}, false, 'sample', 1, 0]); // [true, {}, 'sample', 1]
filterFalsy(['', true, {}, false, 'sample', 1, 0]); // [true, {}, 'sample', 1]
```
</details>
@ -5839,6 +5840,30 @@ const median = arr => {
median([5, 6, 50, 1, -5]); // 5
```
</details>
<br>[⬆ Back to top](#contents)
### midpoint
Calculates the midpoint between two pairs of (x,y) points.
Destructure the array to get `x1`, `y1`, `x2` and `y2`, calculate the midpoint for each dimension by dividing the sum of the two endpoints by `2`.
```js
const midpoint = ([x1, y1], [x2, y2]) => [(x1 + x2) / 2, (y1 + y2) / 2];
```
<details>
<summary>Examples</summary>
```js
midpoint([2, 2], [4, 4]); // [3, 3]
midpoint([4, 4], [6, 6]); // [5, 5]
midpoint([1, 3], [2, 4]); // [1.5, 3.5]
```
</details>
<br>[⬆ Back to top](#contents)