Travis build: 765 [ci skip]

This commit is contained in:
Travis CI
2018-01-01 12:38:25 +00:00
parent e427fd9cdc
commit a0bb2eb597
4 changed files with 48 additions and 6 deletions

View File

@ -272,6 +272,7 @@
<details>
<summary>View contents</summary>
* [`join`](#join)
* [`sortedIndex`](#sortedindex)
</details>
@ -4589,6 +4590,35 @@ yesNo('Foo', true); // true
---
## _Uncategorized_
### join
Joins all elements of an array into a string and returns this string. Uses a separator and an end separator.
Use `Array.reduce()` to combine elements into a string.
Omit the second argument, `separator`, to use a default separator of `','`.
Omit the third argument, `end`, to use the same value as `separator` by default.
```js
const join = (arr, separator = ',', end = separator) =>
arr.reduce(
(acc, val, i) =>
i == arr.length - 2
? acc + val + end
: i == arr.length - 1 ? acc + val : acc + val + separator,
''
);
```
```js
join(); // ''
join(['pen', 'pineapple', 'apple', 'pen'], ',', '&'); //"pen,pineapple,apple&pen"
join(['pen', 'pineapple', 'apple', 'pen'], ','); //"pen,pineapple,apple,pen"
join(['pen', 'pineapple', 'apple', 'pen']); //"pen,pineapple,apple,pen"
```
<br>[⬆ back to top](#table-of-contents)
### sortedIndex
Returns the lowest index at which value should be inserted into array in order to maintain its sort order.