Created
July 16, 2015 20:40
-
-
Save ewilazarus/8b6c932fd1f2c5b36f32 to your computer and use it in GitHub Desktop.
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
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