Last active
December 10, 2019 07:35
-
-
Save Dromediansk/4e33b74c58b3e0da04d2d2a924f8d8a9 to your computer and use it in GitHub Desktop.
Data encapsulation with closure
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
| const monitorProductivityTime = () => { | |
| let timeWithoutReset = 0; | |
| const productivityTime = () => timeWithoutReset++; | |
| const totalProductivityTime = () => timeWithoutReset; | |
| const reset = () => { | |
| timeWithoutReset = -1; | |
| return 'production time has been restarted!'; | |
| } | |
| setInterval(productivityTime, 1000); | |
| return { | |
| totalProductivityTime, | |
| reset | |
| } | |
| } | |
| const holdTime = monitorProductivityTime(); | |
| holdTime.totalProductivityTime(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment