I have the following two arrays:
const firstArr = [1, 2, 3, 4]
const secondArr = ['somevalue', 'anothervalue', 'another', 'other']
I would like to get the following output:
const final = [[1, 'somevalue'], [2, 'anothervalue'], [3, 'another'], [4, 'other']]
Where each value of the two arrays is associated with another value and put into an array. So for example, the first value of firstArr
should be associated with the first value of secondArr
in a sub-array on the final
array.
Is there some function in Javascript to do this or am i going to have to do it another way, for example with a loop?