Is there a way to do this? Am using conditions to handle which numbers ARE allowed and to display an error if invalid numbers are entered. But can't get it to stop letters etc from being entered/processed.
Hopefully I'm having a Friday moment and missing something simple
Thanks so much Michael that has fixed it. The only thing I found was that if you only put some numbers in then total it the Nan is back! Do you know why that happens?
I have successfully built out a calculation slide that works well when previewed. I have duplicated the slide in the same scene with the hopes of changing the scenario users will work through. Before making any changes to the duplicate slide I tested it and it's getting the the "NaN" error. Why would something work fine then when I duplicate it no longer work? I have read through the responses above and have not been able to fix the issue.
NAN is 'Not A Number' error in JavaScript. If you are not using custom JavaScript code then it bares down to extremely bad coding on the developer's side. The developer has to trap any strings, Infinity numbers and spaces or any other value the user may enter that is not a number value. Sloppy code writing.
Any chance you could share your file? If folx can see what you have going in your project, it'll be easier to pinpoint what's going on and make suggestions!
Thanks for sharing the solution that worked for you in this thread, Kevin! I'm sure it will be helpful to other community members that come across this post.
39 Replies
It would be easier to help, if you can share your .story file (or the one slide) here.
Hi Michael
Please see attached.
Many thanks
Amanda
Have a look at the attached and see if that's what you wanted. I corrected some triggers and added some to calculate the total score.
Thanks so much Michael that has fixed it. The only thing I found was that if you only put some numbers in then total it the Nan is back! Do you know why that happens?
You could set the variables to a defined value to avoid "blanks". See attached a revised file.
Sorry Micheal, I can't easily see what is different - which variable have you altered?
I just added slide triggers for each of the numeric variables to make sure they start off with a defined value of 0.
Brilliant thank you this is working perfectly now.
This post was removed by the author
This post was removed by the author
This post was removed by the author
I have successfully built out a calculation slide that works well when previewed. I have duplicated the slide in the same scene with the hopes of changing the scenario users will work through. Before making any changes to the duplicate slide I tested it and it's getting the the "NaN" error. Why would something work fine then when I duplicate it no longer work? I have read through the responses above and have not been able to fix the issue.
NAN is 'Not A Number' error in JavaScript. If you are not using custom JavaScript code then it bares down to extremely bad coding on the developer's side. The developer has to trap any strings, Infinity numbers and spaces or any other value the user may enter that is not a number value. Sloppy code writing.
I didn't use any Javascript (I'm new to Storyline) and simply used the the programing within Storyline to assign variables and so on. I used this tutorial to build it. https://community.articulate.com/articles/setting-variables-to-perform-a-calculation-in-articulate-storyline
Hi Sarah!
Any chance you could share your file? If folx can see what you have going in your project, it'll be easier to pinpoint what's going on and make suggestions!
Found this old thread when trying to solve the same issue in JavaScript. Thought I'd post here in case anyone else needs this solution:
a = a || 0
adding || 0 tell JS that if there's errors on the left side (e.g. NaN) then return a value of 0.
This post was removed by the author
Thanks for sharing the solution that worked for you in this thread, Kevin! I'm sure it will be helpful to other community members that come across this post.
Have a great day, and happy developing! ✨