Object.fromEntriesbeginner// Build an object from [key, value] pairs
const entries = [['a', 1], ['b', 2]]
Object.fromEntries(entries) // β { a: 1, b: 2 }Use Object.fromEntries() to convert an iterable of [key, value] pairs into a plain object.
Object.fromEntries(iterable) transforms an iterable of [key, value] pairs into a plain object. It is the inverse of Object.entries.
Challenge: Implement pairsToObject(pairs) that converts an array of [key, value] pairs into an object.
pairsToObject([['a', 1], ['b', 2]]) // β { a: 1, b: 2 }