Compare every consecutive character with the odd value
if ( checkOdd ( num_str . charAt ( x ) ) && checkOdd ( num_str . charAt ( x + 1 ) ) ) { result_str . insert ( x + 1 , " - " ) ; num_str = result_str . toString ( ) ; x ++ ; } }