A Pen by Machiko Yasuda
A Pen by Machiko Yasuda on CodePen.
A Pen by Machiko Yasuda on CodePen.
// 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; | |
} |