I have a data structure like this:
const arr1 = [["name1", "123", "prop2"],["name2", "43", "prop22"], ["name3", "22", "prop3"]];
const arr2 = [[156, 154, "position report"],[173, 124, "position report"],[136, 154, "position report"]];
I want the final array to look like this:
finalArr = [["name1", "123", "prop2",156, 154, "position report], ["name2", "43", "prop22",173, 124, "position report"],["name3", "22", "prop3", 136, 154, "position report"]]
Basically I want to merge the sub-array elements of arr1 to arr2 in a new final array. I have tried to use this code but it just only merge the 2 arrays but not the sub elements
let newArr = [];
arr1.forEach((item) => {
arr2.forEach((element) => {
newArr.push({ ...item, element });
});
});
console.log(newArr);
Any ideas using only the ES6 notations?