Use isNaN() to check for NaN values.

`NaN` can never be equal to itself, so checking if `val !== NaN` won't work as expected. `isNaN()` should be used instead.