Created
March 24, 2015 04:07
-
-
Save timkg/309a6d12741638c486be to your computer and use it in GitHub Desktop.
Map-Reduce a collection of values into a list
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
[1, 2, 3] | |
.map(function (num) { | |
var listItem = document.createElement('li'); | |
listItem.textContent = num; | |
return listItem; | |
}) | |
.reduce(function (acc, cur) { | |
acc.appendChild(cur); | |
return acc; | |
}, document.createElement('ul')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment