Last active
August 22, 2016 05:03
-
-
Save NateJLewis/2ca667dd8a94185fbcc686d0101c05e3 to your computer and use it in GitHub Desktop.
Playing with higher-order functions.
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
function makeConcatenater ( left ) { | |
return function ( right ) { | |
return left + ' ' + right; | |
} | |
} | |
var addString = makeConcatenater ( 'Hello' ); | |
addString( 'World' ); | |
/////////////////////////////// | |
function makeAdder ( left ) { | |
return function ( right ) { | |
return left + right; | |
} | |
} | |
var add5 = makeAdder( 5 ); | |
add5(20) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment