Here's the scenario: I'm encountering an issue where I am invoking a function within another function. This inner function has the capability to return either a string or a number, and my goal is to combine that with another value. However, I keep running into an error.
I attempted to address this by implementing a check
function addNumbers(obj):number | string {
const returnedValue = helperFunction(obj.blah) //this could be a number or string
if (Number.isNaN(returnedValue) === false) {
return returnedValue + anotherValue;
}
return ‘-’;
I thought using Number.isNaN would solve the problem but unfortunately, it did not. Any suggestions?