Q:

Write a JavaScript program to create an array of key-value pair arrays from a given object

0

Write a JavaScript program to create an array of key-value pair arrays from a given object.

All Answers

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

const object_to_pairs = obj => Object.keys(obj).map(k => [k, obj[k]]);
console.log(object_to_pairs({ a: 1, b: 2 }));
console.log(object_to_pairs({ a: 1, b: 2, c: 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