QUESTION IMAGE
Question
jump to level 1
surround the call to processnumbers with a try - catch statement. the catch block should display the thrown message an assign processedvalue with - 1.
1 let numberlist = 1, 2, 5, 7 ; // code will be tested with different arrays.
2 let processedvalue = 0;
3
4 processedvalue = processnumbers(numberlist);
5
Step1: Add try block
try {
processedValue = processNumbers(numberList);
}
Step2: Add catch block
catch (error) {
console.log(error.message);
processedValue = -1;
}Snap & solve any problem in the app
Get step-by-step solutions on Sovi AI
Photo-based solutions with guided steps
Explore more problems and detailed explanations
let numberList = [1, 2, 5, 7]; // Code will be tested with different arrays.
let processedValue = 0;
try {
processedValue = processNumbers(numberList);
} catch (error) {
console.log(error.message);
processedValue = -1;
}