Skip to content

Instantly share code, notes, and snippets.

@philmander
Last active August 29, 2015 14:12
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 philmander/d6ffb7fae279959f22d1 to your computer and use it in GitHub Desktop.
Save philmander/d6ffb7fae279959f22d1 to your computer and use it in GitHub Desktop.
Object array to html string with Array.reduce()
var items = [{
html: '<p>One</p>'
}, {
html: '<p>Two</p>'
}, {
html: '<p>Three</p>'
}];
var html = items.reduce(function(html, item) {
html.push(item.html);
return html;
}, []).join("");
//html = '<p>One</p><p>Two</p><p>Three</p>'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment