I have been given these two tasks. I’m not asking you to do the tasks for me; what I need is greater understanding.
Write JavaScript™ code that anticipates and handles an error for an expected numeric field. This code is executed on keypress, and the entered value is saved for you in a variable called
enteredChar
. Include thetry
block of JavaScript™ statements needed to check if the character is not a number or a non-alphanumeric character, or if you throw an error message.Write a custom error handling JavaScript™ function called
processErrors
that handles a custom error by assigning it to theonerror
event handler. Include the block of JavaScript™ statements needed to pass the arguments sent by the JavaScript™ interpreter into theprocessErrors
function, send an alert message with the agreements, return, and write the event handler that calls theprocessErrors
function.
What I am supposed to do? I am brand new to JavaScript and I am unsure what I have been asked to do.
I think the first one is asking me to write a code that stops anything but numbers and letters from running in the program?
The second one I think is asking me to code for some kind of error, but I am not sure what.
I am looking for clarification.