Skip to content

Instantly share code, notes, and snippets.

@jimmyhchan
Last active August 29, 2015 14:17
Show Gist options
  • Save jimmyhchan/8cd494cb0067e3edf3e9 to your computer and use it in GitHub Desktop.
Save jimmyhchan/8cd494cb0067e3edf3e9 to your computer and use it in GitHub Desktop.
if else in function
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