functiongreeting(name) {
alert('Hello ' + name);
}
functionprocessUserInput(callback) {
var name = prompt('Please enter your name.');
callback(name);
}
processUserInput(greeting);
functiongreeting(name) {
alert('Hello ' + name);
}
functionprocessUserInput(callback , {
var name = prompt('Please enter your name.');
callback(name);
}}
processUserInput(greeting);
//Callback functions - are functions that are called AFTER something happenedconst foo = (number, callbackFunction) => {
//first console.log(number)
//second - runs AFTER console.log() happened
callbackFunction()
}
functioncreateQuote(quote, callback){
var myQuote = "Like I always say, " + quote;
callback(myQuote); // 2
}
functionlogQuote(quote){
console.log(quote);
}
createQuote("eat your vegetables!", logQuote); // 1// Result in console: // Like I always say, eat your vegetables!