JS Built-ins
ObjectObject.entriesintermediate

Object.entries() β€” string values

πŸ“– Usage Example
// Get [key, value] pairs of an object
const obj = { a: 1, b: 2 }
Object.entries(obj)   // β†’ [['a', 1], ['b', 2]]

Use Object.entries() to get an array of [key, value] pairs for iterating over an object's own enumerable properties.

Object.entries() β€” iterating for transformation

Object.entries is often used to iterate over an object's properties to transform or filter them.

Challenge: Implement upperValues(obj) that returns a new object with all string values uppercased, using Object.entries.

upperValues({ a: 'hello', b: 'world' }) // β†’ { a: 'HELLO', b: 'WORLD' }
πŸ’‘ Hints (1)
  • β€’ Use `Object.entries(obj).map(([k, v]) => [k, v.toUpperCase()])` then wrap with `Object.fromEntries`.