Skip to content

Instantly share code, notes, and snippets.

@robertcoopercode
Created January 9, 2019 00:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robertcoopercode/14d19fd717aacfe56bb0cb5feb4bd3cf to your computer and use it in GitHub Desktop.
Save robertcoopercode/14d19fd717aacfe56bb0cb5feb4bd3cf to your computer and use it in GitHub Desktop.
// The `name` parameter can be either a string or null
const sayHappyBirthdayOnFacebook = (name: string | null) => {
if (name === null) {
console.log('Happy birthday!');
} else {
console.log(`Happy birthday ${name}!`);
}
};
sayHappyBirthdayOnFacebook(null); // => "Happy birthday!"
sayHappyBirthdayOnFacebook('Jeremy'); // => "Happy birthday Jeremy!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment