How can I get 'return True' by exponent in JavaScript?

71 Views Asked by At

First, I'm sorry I can't speak English well.

I have some problems studying JS. I want to return true if the string is a Number.

If string is "0x10", "0b10", "9843" it work well (all return true). And string like "a463" return false well.

But, when the string is a string with an exponent like "1e43"... it doesn't work well. (it's return false) I want to return true when string with exponent.

if (isNaN(s - 0)) {
  return false;
} else {
  return true;
}

I think have a problem with if().

So, How can I get return true, when the string is with exponent, like "1e22", "13e7"?

0

There are 0 best solutions below