Skip to content

Instantly share code, notes, and snippets.

@philmander
Last active August 29, 2015 14:12
Show Gist options
  • 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