Array merging method

var arr1= ["name"," age", "home"]
var arr2= [[" aqiang "name":"a","age":1," home":"one"}, "daddy,""e"], [1 one", "two"," three", "four"," five"]
var arr3= [{"name":"a","age":1," home":"one"}, {"name":"b","age":2,"] "home":"two"}, {" name":"c","age":3, "home":"three"}, {" name":"d","age":4, "home":"four"}, {" name":"e","age":5, "home":"five"}];
known arrays 1 and 2, write a way to get the form of array 3

Mar.15,2021

function trans (names, arr) {
  let result = []
  for (let i = 0, len = arr[0].length; i < len; iPP) {
    let obj = {}
    names.forEach((name, index) => {
      obj[name] = arr[index][i]
    })
    result.push(obj)
  }
  return result
}

var arr1=['name', 'age', 'home']
var arr2=[['a', 'b', 'c', 'd', 'e'], [1,2,3,4,5], ['one', 'two', 'three', 'four', 'five']]
trans(arr1, arr2)

var arr1= ['name',' age', 'home']
var arr2= [[' await, 'baked,' cynical, 'dagger,' e'], [one', 'two',' three', 'four',' five']
arr2 [0] .map ((item, index) = > {

return arr1.reduce((a, b, i) => (a[b] = arr2[i][index], a), {})

})

Menu