0

Im trying to pass the test of my lesson but answer of a test dont mach result im getting from JS Bin. My task is:

let unknown = undefined;
let sum = unknown + 1;
let typeOfSum = typeof sum;
console.log(typeOfSum);

Answer of test should be 'NaN'

BUT!

When I'm trying this code in JS Bin, I get result 'number'

Please, help me to understand, why I'm not getting NaN if it should be NaN?

Praveen Kumar Purushothaman
  • 164,888
  • 24
  • 203
  • 252

1 Answers1

0

JavaScript works this way. There's no typeof output that's NaN. The answer is here:

answer

Yes, you're right. undefined + 1 is NaN.

But typeof NaN is a 'number' always.

Praveen Kumar Purushothaman
  • 164,888
  • 24
  • 203
  • 252