Skip to content

Instantly share code, notes, and snippets.

@NyaGarcia
Last active March 2, 2021 17:39
Show Gist options
  • Save NyaGarcia/f7eb0f30d93011ce2d52771daf3dd3ce to your computer and use it in GitHub Desktop.
Save NyaGarcia/f7eb0f30d93011ce2d52771daf3dd3ce to your computer and use it in GitHub Desktop.
A function containing a nested if
function publishTweet(tweet) {
if (isLoggedIn()) {
if (tweet) {
if (isTweetDoubleChecked()) {
tweetIt(tweet);
} else {
throw new Error('Dont publish without double checking your tweet');
}
} else {
throw new Error("Your tweet is empty, can't publish it");
}
} else {
throw new Error('You need to log in before tweeting');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment