Last active
June 24, 2018 18:15
-
-
Save sevperez/ab9ed78641a3df8921a75a32140e340d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function speak(string) { | |
console.log(string); | |
} | |
var delayedFunction = function(fn) { | |
return function(val, delay) { | |
setTimeout(function() { | |
fn(val); | |
}, delay); | |
}; | |
}; | |
var delayedSpeak = delayedFunction(speak); | |
delayedSpeak("I'm late!", 1000); // logs "I'm late" after a 1 second delay |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment