Last active
March 2, 2021 17:39
-
-
Save NyaGarcia/f7eb0f30d93011ce2d52771daf3dd3ce to your computer and use it in GitHub Desktop.
A function containing a nested if
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
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