Last active
August 29, 2015 14:17
-
-
Save jimmyhchan/8cd494cb0067e3edf3e9 to your computer and use it in GitHub Desktop.
if else in function
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
function sayHello(name, lang) { | |
var greet; | |
if (lang === 'es') { | |
greet = 'hola'; | |
} else { | |
greet = 'hello'; | |
} | |
if (name) { | |
console.log(greet + ' ' + name); | |
} else { | |
console.log(greet + ' world'); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment