Skip to content

Instantly share code, notes, and snippets.

@granmoe
Last active April 16, 2018 02:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save granmoe/20d8b2b0ca0b691c9ffa3940e328e2ad to your computer and use it in GitHub Desktop.
Save granmoe/20d8b2b0ca0b691c9ffa3940e328e2ad to your computer and use it in GitHub Desktop.
const addPrefix = prefix => reduce((result, [key, val]) => {
result[prefix + key] = val
return result
}, {})
const myObj = {
foo: 1,
bar: 2
}
addPrefix('yo_')(Object.entries(myObj))
// returns { yo_foo: 1, yo_bar: 2 }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment