Skip to content
Advertisement

Tag: nan

function returning NaN in javascript

I am trying to write a function that calculates the average student age in a list of student objects, but when I run the code the function prints NaN as an output this is how i constructed the array ( i got the input from the user) i tried to calculate the total of student age (removing the divide operation)

Break on NaN in JavaScript

Is there any modern browser that raises exceptions on NaN propagation (ie multiplying or adding a number to NaN), or that can be configured to do so? Silent NaN propagation is an awful and insidious source of bugs, and I’d love to be able to detect them early, even at a performance penalty. Here’s an example bug that use strict,

Advertisement