Skip to content

Instantly share code, notes, and snippets.

@JeremyIglehart
Created January 31, 2016 06:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JeremyIglehart/37b162de3697027865d5 to your computer and use it in GitHub Desktop.
Save JeremyIglehart/37b162de3697027865d5 to your computer and use it in GitHub Desktop.
Greeting Function Factory
function makeGreeting(language) {
return function(firstName, lastName) {
if (language === 'en') {
console.log('Hello ' + firstName + " " + lastName);
}
if (language === 'ua') {
console.log('Privit ' + firstName + " " + lastName);
}
}
}
var greetEnglish = makeGreeting('en');
var greetUkrainian = makeGreeting('ua');
greetEnglish ('Jeremy', 'Iglehart');
greetUkrainian('Iryna', 'Iglehart');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment