Remove recurring digits in a given number | Removes recurring digits in num [ ] ; let j = 0 ; Index in modified string ; Traverse digits of given number one by one ; Copy the first occurrence of new digit ; Remove repeating occurrences of digit ; Driver code
function removeRecurringDigits ( num ) { let len = num . length ; let s = " " ; for ( let i = 0 ; i < len ; i ++ ) { s += ( num [ i ] ) ; while ( i + 1 < len && num [ i ] == num [ i + 1 ] ) { i ++ ; } } return s ; } let num = " " . split ( " " ) ; document . write ( " " + removeRecurringDigits ( num ) ) ;