Forum Discussion

JackCalderone-3's avatar
JackCalderone-3
Community Member
2 years ago

Number Variables Error: NaN

Hello Heroes,

I'm working on a Storyline project that requires me to complete some math in Javascript. This requires very small numbers (decimals near 0.0004) and because Storyline rounds number variables to two decimal points, i'm trying to use Javascript. Ultimately, I am trying to calculate the monthly payment on a home.

In the attached example, the set variables are pulled into JS with the second button and 2 instances of JS math are performed. 

You'll see the code is able to calculate the Principal, but the calculation for Monthly Payment always returns NaN.

I've tested this code in a javascript playground and all of the math checks out. What are some reasons I am returning NaN?