Last active
March 7, 2019 09:50
-
-
Save goxr3plus/7acd34ac3bf70dcf3ff13835a181af30 to your computer and use it in GitHub Desktop.
Javascript Closures example
This file contains 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
//-----------------------Closures ------------------------------// | |
function retirement(retirementAge) { | |
let a = " years until retirement"; | |
return function(yearsOfBirth) { | |
let age = 2019 - yearsOfBirth; | |
console.log(retirementAge - age + a); | |
}; | |
} | |
// let retirementUs = retirement(66); | |
retirement(66)(1995); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment