Created
October 15, 2015 03:02
-
-
Save jalehman/03fa90687aba636d05eb to your computer and use it in GitHub Desktop.
This file contains hidden or 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 each = function(list, f) { | |
for (var i = 0; i < list.length; i++) { | |
f(list[i]); | |
} | |
}; | |
var map = function(list, f) { | |
var arr = []; | |
for (var i = 0; i < list.length; i++) { | |
arr.push(f(list[i])); | |
} | |
return arr; | |
}; | |
var numbers = [0,1,2,3,4,5]; | |
each(numbers, function(x) { console.log(x+1); }); | |
map(numbers, function(x) { return x + 1; }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment