I am working with two data structures:
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 have a specific outcome in mind:
finalArr = [["name1", "123", "prop2",156, 154, "position report], ["name2", "43", "prop22",173, 124, "position report"],["name3", "22", "prop3", 136, 154, "position report"]]
To achieve this, I attempted the following code but it did not fully merge the sub-array elements:
let newArr = [];
arr1.forEach((item) => {
arr2.forEach((element) => {
newArr.push({ ...item, element });
});
});
console.log(newArr);
Are there any solutions using only ES6 syntax?