Created
September 12, 2018 12:37
-
-
Save andijakl/143392d4200a6582ae3b512326ea7921 to your computer and use it in GitHub Desktop.
Try / Catch in JavaScript
This file contains 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
var weight = -12.2; | |
try { | |
if (weight < 0) { | |
throw "Weight can not be less than 0"; | |
} | |
console.log("Saving today's weight to database..."); | |
} catch(error) { | |
console.log(error); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment