Skip to content

Instantly share code, notes, and snippets.

@suhailgupta03
Created May 15, 2023 16:05
Show Gist options
  • Select an option

  • Save suhailgupta03/10e6f8d4b0f97bb0baa61df1172fa410 to your computer and use it in GitHub Desktop.

Select an option

Save suhailgupta03/10e6f8d4b0f97bb0baa61df1172fa410 to your computer and use it in GitHub Desktop.
function greet(message, username) {
// undefined are FALSY values in JS
// !undefined means !false -> true
if(!username) { // if username is not yet defined
username = "user"; // we are assinging it some value
}
var greetMessage = `Hello, ${username}! ${message}`;
console.log(greetMessage);
}
greet("Good evening");
greet("Good evening", "arjun");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment