Q:

Write a JavaScript program to create an object from the given key-value pairs

0

Write a JavaScript program to create an object from the given key-value pairs.

All Answers

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

const object_From_Pairs = arr => arr.reduce((a, v) => ((a[v[0]] = v[1]), a), {});
console.log(object_From_Pairs([['a', 1], ['b', 2]])); 
console.log(object_From_Pairs([[1, 10], [2, 20], [3, 30]]));

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