return the objects keys and values

Solutions on MaxInterview for return the objects keys and values by the best coders in the world

showing results for - "return the objects keys and values"
Francisco
26 Jan 2018
1const keysAndValues = (obj) => [Object.keys(obj), Object.values(obj)];
2
3keysAndValues({a: 1, b: 2, c: 3}); 
4//➞ [["a", "b", "c"], [1, 2, 3]]
5
6keysAndValues({a: "Dell", b: "Microsoft", c: "Google"}));
7//➞ [["a", "b", "c"], ["Dell", "Microsoft", "Google"]]
8
9keysAndValues({key1: true, key2: false, key3: undefined});
10// ➞ [["key1", "key2", "key3"], [true, false, undefined]]
similar questions
queries leading to this page
return the objects keys and values