I have an array of 60 items. I want to split it into an array within an array of 20 items in it.
Here are the codes that I have, but kind of stuck on how to separate into the array.
const initialData = get(certificate, "transcript", []);
const splitData = [];
This is how the splitTranscriptData should look like at the end
[[1,2,3...20],[21,22,23...40],[41,42,43...60]]
I am trying to make this a dynamic way of separating the initial array into 20 items in each array. For example, my initial array has 55 items, the end result will be 3 arrays with the last one having 15 items in it.
When there are more items in the initial array, let's say 70 items, it will split into 4 arrays with the last one having 10 items in it.