I'm having array of arrays like below.
const myArray = [[3,1,1,1],[4,2,1],[5,2],[6]];
I want push an empty string 5 times to each element of this array.
Expected Output Array :
[[3,1,1,1,'','','','',''],[4,2,1,'','','','',''],[5,2,'','','','',''],[6,'','','','','']]
What is the most efficient way to do this?
My approach:
const array1 = [[3, 1, 1, 1],[4, 2, 1],[5, 2],[6]];
const appendArray = new Array(5).fill('');
const map1 = array1.map(x => x.concat(appendArray));
console.log(JSON.stringify(map1));
I'm not sure the efficiency of my approach?