Question: Add a throw statement to the processNumbers function that throws the message Found an element that is not a number. if one of the elements
Add a throw statement to the processNumbers function that throws the message "Found an element that is not a number." if one of the elements in toProcess is not a number. Hint: The function isNaN returns true if the parameter is not a number.
function processNumbersnumberList
let result ;
for let index ; index numberList.length; index
if isNaNnumberListindex
throw new ErrorFound an element that is not a number.";
result numberListindex index;
return result;
Answer above needs corrected as it shows the following error
"Testing if an exception is thrown with toProcess
Yours and expected differ. See highlights below.
Yours
Yes
Expected
No
the code below needs fixed
if isNaNnumberListindex
throw ErrorFound an element that is not a number.";
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
