javascript888,
<script>
let arr = [1, 2, 3, 4, 5, 6, 7, 8, 9];
function normalizeArr(arr, cols, box) {
let length = cols - (arr.length % cols || cols);
for (; length--; ) arr.push(box);
length = arr.length / cols;
return Array.from({length}, (_, i) => arr.slice(i *= cols, i + cols));
}
document.write(JSON.stringify(normalizeArr(arr, 4, '-')));
</script>