Created
August 15, 2017 18:00
-
-
Save NickBaynham/e7bb0cb5fcf43afb6616ea254bf9ca1a to your computer and use it in GitHub Desktop.
Closure Example
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
let zipCode = (code, location) => { | |
let _code = code; | |
let _location = location || ''; | |
return { | |
code: () => { | |
return _code; | |
}, | |
location: () => { | |
return _location; | |
} | |
} | |
} | |
const princetonZip = zipCode('08544', '3345'); | |
console.log(princetonZip.code()); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment