Javascript Object makeObj(arr1, arr2)

Description

Javascript Object makeObj(arr1, arr2)

// Given two arrays make an object with the first array being the keys
function makeObj(arr1, arr2) {
  var obj = {};/*  w  ww.  j a  v  a2  s.c o m*/

  for (var i = 0; i < arr1.length; i++) {
    obj[arr1[i]] = arr2[i];
  }

  return obj;
}



PreviousNext

Related