In this practice, you will practice reading, throwing and handling JavaScript runtime errors.
Clone the starter from the Download link at the bottom of this page.
Implement the following in the error-handling.js file.
sum
function is throwing an error! Determine why the error is thrown, and handle only that particular error type usingtry...catch
. Print the error message if the code is throwing the error type you expect- Create
sayName(name)
function that will print the name that is passed to it ifname
argument is a string. It should throw aTypeError
with a message of "Invalid name! Must be a string!" ifname
is not a string. Run thesayName
function test cases inside oftry...catch
and print out the error message if an error is thrown. - Come up with a test case that will cause the
greeting
function to throw theError
. When an error is thrown from that test case, catch it and print out "Hello World!"