I have this problem where I want to split an array of elements into equal chunks of three. But if the final chunk can't be split evenly then add empty strings.
I am using lodash _.chunk method but not sure how to add extra empty strings in the final chunk.
// I will get unknown number elements in the array.
const arr1 = [{elem1}, {elem2}, {elem3}, {elem4}]
// above array does have 4 elements. If I use _.chunk I will get something like [[{elem1},{elem2},{elem3}], [{elem4}]]
// I am looking to get something like [[{}, {}, {}], [{}, '', '']].
Can somebody please let me know how to achieve this in JS?