Remove duplicates from a given string | javascript program to remove duplicate character from character array and prvar in sorted order ; Create a set using String characters excluding ' \0' ; HashSet doesn 't allow repetition of elements ; Driver code
function removeDuplicate ( str , n ) { var s = new Set ( ) ; for ( var i = 0 ; i < n ; i ++ ) s . add ( str [ i ] ) ; for ( const v of s ) { document . write ( v ) ; } } var str = " " ; var n = str . length ; removeDuplicate ( str , n ) ;