Skip to content

Instantly share code, notes, and snippets.

@ewilazarus
Created July 16, 2015 20:40
Show Gist options
  • Save ewilazarus/8b6c932fd1f2c5b36f32 to your computer and use it in GitHub Desktop.
Save ewilazarus/8b6c932fd1f2c5b36f32 to your computer and use it in GitHub Desktop.
function greet(language, name) {
var hi;
switch(language) {
case "en":
hi = "Hello";
break;
case "pt":
hi = "Oi";
break;
case "de":
hi = "Hallo";
break;
}
console.log(hi + " " + name);
}
function makeGreet(language) {
return greet.bind(this, language);
}
var greetEn = makeGreet("en");
greetEn("Gabriel"); // Hi Gabriel
var greetDe = makeGreet("de");
greetDe("Lucas"); // Hallo Lucas
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment