type here
const array1 = [1, 2, 43, 5];
const arrayofObj = [
{
key: 1,
value: 3,
},
{
key: 2,
value: 10,
},
{
key: 3,
value: 20,
},
{
id: 123,
value: 30,
},
{
id: 123,
value: 30,
},
{
id: 123,
value: 30,
},
{
id: 123,
value: 30,
},
];
// i only come up with that:
]
const add = function(i) {
arrayofobj[i].val = array1[i]
}
add(2)
// but it as you know only adds up to one specific index, so how can i add this value to all elements ? thanks for any help :)
i want to have something like that:
const arrayofobj = [
{
key:1,
value:2,
val: (array1 element that have exact same index)
}