<html> 	<head> 	 <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> 	</head> 	<body> 		<div id="result"></div>  		<script> 			var string = 'aabbaddgdfgfbbbfgsdfgsdfgsbbbbcccdd'; 			var uinqData = string.replace(/(.)(?=.*\1)/g, "") 			var obj ={}; 			for(var i=0;i<uinqData.length;i++){ 			    ele = uinqData.charAt(i); 			    regex = new RegExp(ele, 'g' ); 			    count = string.match(regex).length; 			    $("#result").append(ele + " is repeated " + count + " times"+"<br/>"); 			      			}  			// $.each(obj, function(key, value){ 			//   $("#result").append(key + " is repeated " + value + " times"+"<br/>"); 			// }); 		</script> 	</body> </html>