Created
January 9, 2019 00:30
-
-
Save robertcoopercode/14d19fd717aacfe56bb0cb5feb4bd3cf 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
// 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