Checking if the number contain only 0 , 1 , 8.
for ( var i = 0 ; i < S . length ; i ++ ) { if ( S [ i ] != ' ' && S [ i ] != ' ' && S [ i ] != ' ' ) { return " " ; } } var start = 0 , end = S . length - 1 ;