Travis build: 1045 [cron]
This commit is contained in:
@ -595,10 +595,10 @@
|
||||
"body": [
|
||||
"const differenceBy = (a, b, fn) => {",
|
||||
" const s = new Set(b.map(fn));",
|
||||
" return a.filter(x => !s.has(fn(x)));",
|
||||
" return a.map(fn).filter(el => !s.has(el));",
|
||||
"};"
|
||||
],
|
||||
"description": "Returns the difference between two arrays, after applying the provided function to each array element of both.\n\nCreate a `Set` by applying `fn` to each element in `b`, then use `Array.prototype.filter()` in combination with `fn` on `a` to only keep values not contained in the previously created set"
|
||||
"description": "Returns the difference between two arrays, after applying the provided function to each array element of both.\n\nCreate a `Set` by applying `fn` to each element in `b`, then use `Array.prototype.map()` to apply `fn` to each element in `a`, then `Array.prototype.filter()"
|
||||
},
|
||||
"differenceWith": {
|
||||
"prefix": "30s_differenceWith",
|
||||
@ -778,8 +778,8 @@
|
||||
"const factorial = n =>",
|
||||
" n < 0",
|
||||
" ? (() => {",
|
||||
" throw new TypeError('Negative numbers are not allowed!');",
|
||||
" })()",
|
||||
" throw new TypeError('Negative numbers are not allowed!');",
|
||||
" })()",
|
||||
" : n <= 1",
|
||||
" ? 1",
|
||||
" : n * factorial(n - 1);"
|
||||
@ -2490,9 +2490,9 @@
|
||||
"const remove = (arr, func) =>",
|
||||
" Array.isArray(arr)",
|
||||
" ? arr.filter(func).reduce((acc, val) => {",
|
||||
" arr.splice(arr.indexOf(val), 1);",
|
||||
" return acc.concat(val);",
|
||||
" }, [])",
|
||||
" arr.splice(arr.indexOf(val), 1);",
|
||||
" return acc.concat(val);",
|
||||
" }, [])",
|
||||
" : [];"
|
||||
],
|
||||
"description": "Removes elements from an array for which the given function returns `false`.\n\nUse `Array.prototype.filter()` to find array elements that return truthy values and `Array.prototype.reduce()` to remove elements using `Array.prototype.splice()`.\nThe `func` is invoked with three arguments (`value, index, array`)"
|
||||
|
||||
Reference in New Issue
Block a user