function Chunk(arr = [], size = 1){ return arr.reduce((t, v) => (t[t.length -1].length === size ? t.push([v]) : t[t.length - 1].push(v), t),[[]]); } const arr = [1, 2 , 3, 4, 5]; console.log(Chunk(arr, 2)); function Difference(arr = [], oarr = []){ return arr.reduce((t, v) =>(!oarr.includes(v) && t.push(v), t),[]); } const arr1 = [1, 2, 3, 4, 5]; const oarr = [2, 3, 6]; console.log(Difference(arr1, oarr));