Skip to content

Instantly share code, notes, and snippets.

@kbk0125
Last active April 7, 2016 14:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kbk0125/e784d76a511cb3c13538b0fd2ac76e34 to your computer and use it in GitHub Desktop.
Save kbk0125/e784d76a511cb3c13538b0fd2ac76e34 to your computer and use it in GitHub Desktop.
// 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