I want when the two arguments of function sum are numbers, the code success, but when one of the two arguments is not a number I want to throw an exception.
const sum = (num1: number, num2: number) => { return num1 + num2; }; try { typeof sum(8, 'A') === 'number'; } catch (e) { console.log('the type you entered is NaN'); }
Now as a Test I put a string value instead num2 but the code ran without showing the exception in the consoleI mean it didn't log that 'the type you entered is NaN' from the catch block
catch (e) { console.log('the type you entered is NaN'); }
I want to log that in console when arguments are not numbers, How to make that?