Q:

Write a JavaScript program to return the object associating the properties to the values of a given array of valid property identifiers and an array of values

0

Write a JavaScript program to return the object associating the properties to the values of a given array of valid property identifiers and an array of values.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

const zipObject = (props, values) =>
  props.reduce((obj, prop, index) => ((obj[prop] = values[index]), obj), {});
console.log(zipObject(['a', 'b', 'c'], [1, 2])); 
console.log(zipObject(['a', 'b'], [1, 2, 3]));

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now