Skip to content

Instantly share code, notes, and snippets.

@marklreyes
Created November 30, 2017 22:32
Show Gist options
  • Save marklreyes/736c90cc6b65b7149d5a5152e2c8f8bc to your computer and use it in GitHub Desktop.
Save marklreyes/736c90cc6b65b7149d5a5152e2c8f8bc to your computer and use it in GitHub Desktop.
// https://codeburst.io/learn-how-to-handle-javascript-errors-with-try-throw-catch-finally-83b4f9ef8c6f
try {
let hello = prompt("Type hello");
if (hello !== 'hello'){
throw new Error("Oops, you didn't type hello");
}
}
catch(e) {
alert(e.message);
}
finally {
alert('thanks for playing!');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment