Last active
August 29, 2015 14:12
-
-
Save philmander/d6ffb7fae279959f22d1 to your computer and use it in GitHub Desktop.
Object array to html string with Array.reduce()
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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