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.
- Attempt to run
parseInt()on theinputand assign it to a variableval. - Check if
valequals itself:val === val, store inisSame. - Return both items in an array:
[val, isSame].
01EXAMPLE 1
Input
input = "Error"Output
[NaN, false]Explanation: NaN is not equal to NaN.
Constraints
- Observe that NaN === NaN returns false.
- Return an array [number, boolean].
FundamentalsTypesComparison
JavaScriptSystem handles I/O — write your function only
Loading...
5 Hidden
Input Arguments
input"Error"
Expected Output
[null,false]
Click RUN to test your solution