Skip to content

Instantly share code, notes, and snippets.

@leoallen85
Created March 23, 2016 13:17
Show Gist options
  • Save leoallen85/87b2aa2caeb66319ed94 to your computer and use it in GitHub Desktop.
Save leoallen85/87b2aa2caeb66319ed94 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