Create websites with TailwindCSS
Start building the next great SAAS
Alpine & Tailwind UI Library
Plug'n Play Authentication for Laravel
Create website designs with AI
Blog platform for developers
Build a simple static website
21-day program to build a SAAS
const splitInto = n => (accm, value) => accm.every(e => e.length === n) ?
[...accm, [value]] :
[...accm.slice(0, -1), [...accm[accm.length - 1], value]]
Split an array into chunks with a specified size.
ex.
[1,2,3,4,5,6,7,8].reduce(sliceBy(2), [])
// -> [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ], [ 7, 8 ] ]
[1,2,3,4,5,6,7,8].reduce(sliceBy(3), [])
// -> [ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 7, 8 ] ]
Here is what the above code is doing:
1. It checks if the array is of length n.
2. If it is, then it pushes the value to the end of the array.
3. If it is not, then it slices the array and pushes the value to the end of the sliced array.
\