I am encountering a strange unwanted Number to NaN conversion, without knowing where and why. I am clearly missing something here but I cannot figure out what.
Any suggestion is most welcome ! 😉
Here is the javascript code:
updatedAbsoluteResult = currentlyDisplayedRentability * investment
resultAgainstReferencial = updatedAbsoluteResult - appropriateReferencialRentability * investment
$('#a0').html('currentlyDisplayedRentability: ' + typeof currentlyDisplayedRentability)
$('#a1').html('investment: ' + typeof investment)
$('#a2').html('updatedAbsoluteResult: ' + typeof updatedAbsoluteResult)
$('#a3').html('appropriateReferencialRentability: ' + typeof appropriateReferencialRentability)
$('#a4').html('resultAgainstReferencial: ' + typeof resultAgainstReferencial )
$('#a5').html('resultAgainstReferencial: ' + resultAgainstReferencial )
Here is the HTML output:
currentlyDisplayedRentability: number
investment: number
updatedAbsoluteResult: number
appropriateReferencialRentability: number
resultAgainstReferencial: number
resultAgainstReferencial: NaN
Everything is of Number type, but when I want to return the final result, I get ‘is not a number’ as a result.
Anyone knows why ?
Enjoy your weekends !
A numeric type can return NaN and still be of numeric type. Check the values of updatedAbsoluteResult, appropriateReferencialRentability, and investment to see if any of those are unexpected values. Likely something in that equation has gone awry.