Last active
December 22, 2015 17:29
-
-
Save infantiablue/6506359 to your computer and use it in GitHub Desktop.
JavaScript: Array Handler
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
function forEach(array, action) { | |
for (var i = 0; i < array.length; i++) | |
action(array[i]); | |
} | |
// Example | |
function sum(numbers) { | |
var total = 0; | |
forEach(numbers, function (number) { | |
total += number; | |
}); | |
return total; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment