Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
A Pen by Machiko Yasuda.
// once we defined the function, it worked:
function myFunction() { }
try {
// test your function here
var n = 3;
if (n==4) {
document.write("N == 4.")
else {
throw("Not 4.");
// set condition for knowing try-block was satisfied
// document.write("This means the try block function ran.");
} catch(error){
// if try does not work, catch the error here.
document.write("This means we made it to the exception." + error);
} finally {
// alert, console.log, alerts
document.write(" This is the end.");
body {
font-family: Helvetica;
font-size: 14px;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment