How do I test for NaN?

I wrestled a bear once. picture I wrestled a bear once. · Jul 6, 2012 · Viewed 39.4k times · Source

Possible Duplicate:
Comparing NaN values for equality in Javascript

Can anyone tell me why this is not working?

if(inbperr == NaN) {
    document.getElementById('inbclo').value = "N/A";
}
else {
    document.getElementById('inbclo').value = "%" + inbperr;
}

Instead of returning a percentage value, or "N/A", I want it to return "%NaN".

Answer

Ned Batchelder picture Ned Batchelder · Jul 6, 2012

NaN's are unusual: they are not equal to anything, even themselves. You need to use isNaN(inbperr) to tell whether a value is a NaN or not.