<script> </p> <p> var str = 'hskflassssssssskssssdssssussssghgfhssssdsssfh'; </p> <p> var arr = str.split(''); </p> <p> arr.sort(); </p> <p> str = arr.join(''); </p> <p> var re = /(w)1 /g; </p> <p> var value = ''; </p> <p> var num = 0; </p> <p> str.replace(re,function($0,$1){ </p> <p> if($0.length > num){ </p> <p> num = $0.length; </p> <p> value = $1; </p> <p> } </p> <p> }); </p> <p> alert('Most characters: ' value ', number: ' num); </p> <p> </script>