Need to create new array object from two other arrays in JS
var array1 = ['one', 'two', 'one, 'two'];
var array2 = ['3', '4', '5', '6'];
Here array1[0] = one represents array2[0] = 3 and vice versa.
Need to create a new array object with array1’s value as its key and array2’s value as its value
Output needed
var arrayObj = {"one": [{"0":"3", "1":5} ],"two": [{"0":"4", "1":6}]}
Here 3 and 5 in array2 should push to index "one" and 4 and 6 in array2 should push to index "two" ?
2
Answers
Take an object and collect the value and build a new object with the wanted structure.
Maybe I am mistaken, but it seems to me that OP wants something like this: