I'm trying to check whether a string is all digits. This part is
easy:
function allDigits( str ) {
var foo=str.split( '' ); // better than charAt()?
for( var idx=0; idx < foo.length; idx++ ) {
if( !isDigit(foo[idx]) ) {
return false;
}
}
return true;
}
I'm not sure about how to implement isDigit(). Is this the best way?
function isDigit( s ) {
if( s.length > 1 ) {
return false;
}
var nums='123456789 0';
return nums.indexOf(s) != -1;
}
--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cybers pace.org | don't, I need to know. Flames welcome.