The Invalid Number

EasyAcc. 91.4%
+25 XP 8

Not A Number

If a math conversion fails, javascript returns a special error value called NaN (Not-A-Number). Strangely enough, NaN is the only mathematical value in JavaScript that is completely unequal to itself.

The Assignment

Let's see this strange rule in action on raw inputs.

  1. Attempt to run parseInt() on the input and assign it to a variable val.
  2. Check if val equals itself: val === val, store in isSame.
  3. Return both items in an array: [val, isSame].

01EXAMPLE 1

Inputinput = "Error"
Output[NaN, false]

Explanation: NaN is not equal to NaN.

Constraints

  • Observe that NaN === NaN returns false.
  • Return an array [number, boolean].
FundamentalsTypesComparison
JavaScript
Loading...
5 Hidden

Input Arguments

input"Error"

Expected Output

[null,false]

Click RUN to test your solution