JSFiddle - React, Tailwind, and code Playground
by Torean Joel
HTML
I have an example data set. I want to push this data into an array with a subarray for every 16 pieces of data. I got started, but am stuck. Any ideas?
[ [16 names], [16 names ], [16 names] ]; // This is the output I want.
JavaScript
function data(arr, size) {
var array = [];
while(arr.length > 0){
array.push(arr.splice(0,size));
}
return console.log(array);
}
data(["Michael", "Marc", "John", "David", "Nick", "Mom", "Al", "Marlana", "Max",
"Scooter", "Pat", "George", "Lynne", "Tatyana", "Kim", "Kerry", "Enza", "Matt",
"Liz", "Linda", "Ryan",
"Ed", "Frank", "Christine", "Bill", "Jack", "Jill", "Joe", "Harry", "Red",
"Fred", "Iggy", "Brian", "Bob", "Paul", "Gil", "Damian", "Kip", "Phil", "Curtis", "Aly",
"Richard", "Robin", "Grant", "Ian", "Raptor", "T-Rex", "Stegosaurux", "Triceratops", "Compy"], 16)