I have arrays such as
var arrayVal_Int = ["21", "53", "92", "79"];
var arrayVal_Alpha = ["John", "Christine", "Lucy"];
var arrayVal_AlphaNumeric = ["CT504", "AP308", "NK675"];
- Above
arrayVal_Int
should be considered as (purely) numeric. arrayVal_Alpha
andarrayVal_AlphaNumeric
should be considered as strings.
I need to check that in JavaScript.
Try this:
I had a similar need but wanted to verify if a list contained only integers (i.e., no decimals). Based on the above answers here's a way to do that, which I posting in case anyone needs a similar check.
Thanks @Touffy, for your suggestion.
Using simple JavaScript, you can do something like this:
It will return true;
Shortest solution, evals to
true
if and only if every item is (coercible to) a number: