0

Hi I am solving the JS coding test.

It is to know what is the output .

const number = undefined + 11;
if (number === NaN) {
  document.write("NaN");
} else if (number === 11) {
  document.write("11");
} else {
  document.write("other");
}

I thought the output is the 'NaN' But the output is 'other'

Is anyone knows why the output is 'other'?

I checked with console.log(number) and it showed NaN .. I dont know why if statement shows 'other'

Thank you so much !

정지은
  • 25
  • 3
  • 1
    `NaN === NaN` is `false` – VLAZ Feb 19 '23 at 09:14
  • 1
    `NaN` is not equal to anything, not even to itself. Reading [the documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NaN) is always useful. – Teemu Feb 19 '23 at 09:14

0 Answers0