I have 2 arrays:
First array is array of strings:
let array1 = ['value1', 'value2', 'value3', 'value4', 'value5']
second is array of objects that can vary, meaning sometimes I will have all the values sometimes only some and they will not be sorted. Something like this:
array2 = [
{
property1: 'value1',
property2: 42,
property3: 'some other value'
},
{
property1: 'value3',
property2: 342,
property3: 'some other value'
},
{
property1: 'value5',
property2: 422,
property3: 'some other value'
}
]
I need to make another array. If there is value1 from first array inside array2 I need to push to newly created array property2, if not I need to push 0. Order of the items needs to be the same as the array 1 meaning that in the end I will have an array that looks like this:
array3 = [42, 0, 342, 0, 422]
Thanks
I have looked up on stackoverflow but no solution worked for me