Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

divide an array based on length js

let chunk = (arr, size) => arr.reduce((acc, e, i) => (i % size ? acc[acc.length - 1].push(e) : acc.push([e]), acc), []);
let xy = ['2','4','6','7','8','10','20','33','35']
console.log(chunk(xy, xy.length))
Source by www.codegrepper.com #
 
PREVIOUS NEXT
Tagged: #divide #array #based #length #js
ADD COMMENT
Topic
Name
1+4 =