Created
December 28, 2022 06:30
-
-
Save IacovColisnicenco/7770023a0f454b3a59d200478ed1c4e7 to your computer and use it in GitHub Desktop.
Замыкания в Javascript
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
const helloGuest = function(nameGuest) { | |
const dt = new Date(); | |
const hour = dt.getHours(); | |
return function(){ | |
if(hour >= 0 && hour <6 ) { | |
console.log(`Good Night ${nameGuest}`); | |
} | |
else if (hour > 6 && hour < 12) { | |
console.log(`Good Morning ${nameGuest}`); | |
} | |
else if (hour > 12 && hour < 18) { | |
console.log(`Good Afternoon ${nameGuest}`); | |
} | |
else { | |
console.log(`Good Evening ${nameGuest}`); | |
} | |
}; | |
}; | |
const hello = helloGuest('Petea'); | |
hello(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment