JavaScript · Middle · Question 47 of 75
What does Object.fromEntries(Object.entries({ a: 1, b: 2 }).map(([k, v]) => [k, v * 10])) return?
- ✓Correct answer:
{ a: 10, b: 20 } - 2
[['a', 10], ['b', 20]] - 3
{ 0: ['a', 10], 1: ['b', 20] }
Explanation
Object.entries turns an object into an array of pairs that array methods work with, and Object.fromEntries collects pairs back into an object. This is the standard way to "map over an object". For grouping there's Object.groupBy.