Looking for a way to enhance a set of objects with properties sourced from another array? I have two arrays at hand. The first one contains a series of objects, while the second one consists of integers. My goal is to attribute a new property to each object in the first array using values from the second array.
For instance:
var arrOfObj = [
{
name: "eve"
},
{
name: "john"
},
{
name: "jane"
}
];
var arr = [0, 1, 2]
//Expected outcome
var arrOfObj = [
{
name: "eve",
num: 0
},
{
name: "john",
num: 1
},
{
name: "jane",
num: 2
}
];
Your guidance is greatly appreciated!