. Advertisement .
..3..
. Advertisement .
..4..
I’m interested in “Javascript count character in string”. But there are many different sources on the Internet, if you have any specific examples, please share them with me. Thank you very much!
Ideas for “Javascript count character in string”: The code to count all characters in string.function countAllChars(str) {
var a = str.split("");
var obj = {};
a.forEach(function(s){
var count=0;
for(var j=0;j<a.length;j++){
if(s==a[j]){
count+=1;
}
obj[a[j]]=count;
}
});
return obj;
}
console.log(countAllCharacters('ittutoria'));
This is my approach
You can try this way
Here is my code, you can try
You can try this way
This is my example
This is the command I use, you can try