How to write a javascript code that counts each character occurrence in a string ?
e.g String is : Hello World Output : count of H -> 1 count of e -&
this code should work:
var str = "Hello World"; var arr = str.split(''); var occ = {}; for(var i=0,c=arr.length;i '+occ[i]); }