Skip to content
Onsite

Check if Variable Is a Number

EasyP3Coding

Implement isNumber(value), which returns true if value is a number and false otherwise.

Rules:

  • A primitive number counts, including negatives, 0, -0 and Infinity.
  • NaN does not count, although typeof NaN is "number".
  • Numeric strings ("5"), Number wrapper objects (new Number(5)), null, undefined, booleans, arrays and BigInt values do not count.

Example 1

Input
isNumber(42), isNumber('42'), isNumber(NaN)
Output
true, false, false

Constraints

  • value can be of any type.

Hints

Run checks the 3 visible tests, Submit all 7.