Skip to content

Instantly share code, notes, and snippets.

@MonaTem
Forked from leoallen85/async_and_callbacks.js
Created September 17, 2017 21:31
Show Gist options
  • Save MonaTem/9b2131fc64c7fc7898abaf55ddc3a278 to your computer and use it in GitHub Desktop.
Save MonaTem/9b2131fc64c7fc7898abaf55ddc3a278 to your computer and use it in GitHub Desktop.
Exercises for understanding asynchronous JS and callbacks.
// Callbacks
// Complete this function so that it passes the numbers 1 and 2 into the callback
function two_numbers(callback){
// TODO
}
two_numbers(function(x, y){
console.log(x, y);
}
// Async and callbacks
// Complete this function using setTimeout to only pass the message to the callback
// after the defined delay
function afterTimeout(message, delay, callback) {
// TODO
}
function afterTimeout("hello world", 1000, function(message){
console.log(message);
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment