new arrray remove and concat issue fixed

This commit is contained in:
sabareesh
2017-12-15 11:41:51 +05:30
parent 123ca7943f
commit 4e7085b5ba
3 changed files with 15 additions and 2 deletions

View File

@ -3,6 +3,6 @@
Use `Array.concat()` to concatenate and array with any additional arrays and/or values, specified in `args`.
```js
const ArrayConcat = (arr, ...args) => arr.concat(...args);
const ArrayConcat = (arr, ...args) => [].concat(arr, ...args);
// ArrayConcat([1], [1, 2, 3, [4]]) -> [1, 2, 3, [4]]
```

View File

@ -4,9 +4,11 @@ Remove elements from `arr` that are returns truthy. Use `Array.filter()` to find
```js
const remove = (arr, func) =>
Array.isArray(arr) ?
arr.filter(func).reduce((acc, val) => {
arr.splice(arr.indexOf(val), 1)
return acc.concat(val);
}, [])
: [];
//remove([1, 2, 3, 4], n => n % 2 == 0) -> [2, 4]
```