Last active
April 7, 2016 14:50
-
-
Save kbk0125/e784d76a511cb3c13538b0fd2ac76e34 to your computer and use it in GitHub Desktop.
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
// generic reportOrders that shows your orders to the function | |
function reportOrders (minionOrders) { | |
if ( typeof minionOrders === "string"){ | |
console.log(minionOrders); | |
} | |
else if ( typeof minionOrders === "object"){ | |
for (var item in minionOrders) { | |
console.log(item + ": " + minionOrders[item]); | |
} | |
} | |
} | |
// A function that takes two parameters, the last one a callback function | |
function speakOrders (orders, minion) { | |
minion(orders); | |
} | |
| |
// When we call the speakOrders function, we pass reportOrders as a parameter. | |
// So reportOrders will be the function that will called back (or executed) inside the speakOrders function | |
speakOrders ({name:"Minion1031", speciality:"Scribe"}, reportOrders); | |
// Console | |
// name: Minion1031 | |
// speciality: Scribe |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment