04·10
2016
It's possible to use one function inside another, this is very handy when we want to write declarative code. Here's a simple example of how this works.
// DEFINITIONS
var larryFunc = function() {
return 'larry';
}
var maryFunc = function() {
return('mary')
}
// need to define a function called introducing
// should take a function as input
var introducing = function(inputFunction) {
console.log("introducing... " + inputFunction() + "!");
}
// TESTING
introducing(larryFunc)
introducing(maryFunc)
For a quick way to test javascript snippets try Matt Keas's Javascript Console on Github. To see logs in the output window, just use log() instead of console.log().