Change NaN

It's better to test for NaN using the popular idiom of not equality to itself, because isNaN returns true for all the values that can be coerced to NaN, for example for any string.