30-seconds-of-code: Update explanation for mapObject

Created on 18 Feb 2020  路  2Comments  路  Source: 30-seconds/30-seconds-of-code

mapObject's explanation is not up to standards with our current format. It should be updated to match the rest of the snippets.

We could also make the example a one-liner.

enhancement good first issue not-stale

Most helpful comment

Perhaps a simpler implementation:

const mapObject = (arr, fn) => Object.assign(...arr.map(el => ({ [el]: fn(el) })))

All 2 comments

Perhaps a simpler implementation:

const mapObject = (arr, fn) => Object.assign(...arr.map(el => ({ [el]: fn(el) })))

@ezracelli do you want to make a PR?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

emelendez picture emelendez  路  4Comments

ecwyne picture ecwyne  路  4Comments

henrycjchen picture henrycjchen  路  4Comments

Lucien-X picture Lucien-X  路  5Comments

kingdavidmartins picture kingdavidmartins  路  5Comments