Skip to content

Instantly share code, notes, and snippets.

@adambene
Last active July 2, 2022 15:29
Show Gist options
  • Save adambene/80694b5e7299b2f3a8d7e665b05c8a49 to your computer and use it in GitHub Desktop.
Save adambene/80694b5e7299b2f3a8d7e665b05c8a49 to your computer and use it in GitHub Desktop.
Currying in JavaScript ES6 - render HTML
renderHtmlTag = tagName => content => `<${tagName}>${content}</${tagName}>`
renderDiv = renderHtmlTag('div')
renderH1 = renderHtmlTag('h1')
console.log(
renderDiv('this is a really cool div'),
renderH1('and this is an even cooler h1')
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment