Write .chunk()
This commit is contained in:
parent
0f1839555d
commit
75aabcdb76
1 changed files with 13 additions and 0 deletions
13
lodash/_.js
13
lodash/_.js
|
@ -78,5 +78,18 @@ _.dropWhile = function (arr, cb) {
|
||||||
return this.drop(arr, dropTo)
|
return this.drop(arr, dropTo)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------- chunk ---- */
|
||||||
|
|
||||||
|
_.chunk = function (arr, size = 1) {
|
||||||
|
const res = []
|
||||||
|
|
||||||
|
for (let i = 0; i < arr.length; i += size) {
|
||||||
|
res.push(arr.slice(i, i + size))
|
||||||
|
console.log(res)
|
||||||
|
}
|
||||||
|
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
// Do not write or modify code below this line.
|
// Do not write or modify code below this line.
|
||||||
module.exports = _
|
module.exports = _
|
||||||
|
|
Loading…
Reference in a new issue