Travis build: 740 [ci skip]

This commit is contained in:
Travis CI
2017-12-31 15:16:08 +00:00
parent f0c246db3e
commit 92e67e7fc3
4 changed files with 46 additions and 4 deletions

View File

@ -8,12 +8,12 @@ Use `Array.findIndex()` to find the appropriate index where the element should b
```js
const sortedIndex = (arr, n) => {
const isDescending = arr[0] > arr[arr.length - 1];
const index = arr.findIndex(el => isDescending ? n >= el : n <= el);
const index = arr.findIndex(el => (isDescending ? n >= el : n <= el));
return index === -1 ? arr.length : index;
};
```
```js
sortedIndex([5,3,2,1], 4); // 1
sortedIndex([30,50],40); // 1
sortedIndex([5, 3, 2, 1], 4); // 1
sortedIndex([30, 50], 40); // 1
```