Created
March 18, 2014 11:07
-
-
Save frankstallone/9617993 to your computer and use it in GitHub Desktop.
Function Queue
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 puzzlers = [ | |
function ( a ) { return 8*a - 10; }, | |
function ( a ) { return (a-3) * (a-3) * (a-3); }, | |
function ( a ) { return a * a + 4; }, | |
function ( a ) { return a % 5; } | |
]; | |
var start = 2; | |
var applyAndEmpty = function( input, queue ) { | |
var length = queue.length; | |
for(var i = 0; i<length; i++){ | |
input = queue.shift()(input); | |
} | |
return input; | |
}; | |
alert(applyAndEmpty(2, puzzlers)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment