Skip to content

Instantly share code, notes, and snippets.

@kbk0125
Last active Feb 15, 2018
Embed
What would you like to do?
// 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, callback) {
callback (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