Last active
March 20, 2016 02:51
-
-
Save JasonDeving/48d70b22c1a83e98fd82 to your computer and use it in GitHub Desktop.
passing arguments as callbacks
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 increment = function(n){ return n + 1; }; | |
var square = function(n){ return n*n; }; | |
var doMath = function(n, func){ return func(n); }; | |
var squareAnswer = doMath(5, square); | |
var plusOne = doMath(4, increment); | |
console.log(squareAnswer); | |
console.log(plusOne); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment