标签:++ java var log hello asc max type null
<script type="text/javascript">
var str="hellomainlanguageoo";
var obj={};
for(var i=0;i<str.length;i++){
var chars=str.charAt(i);
if(obj[chars]){
obj[chars]++;
}else{
obj[chars]=1;
}
}
console.log(obj);
var max=0;
var maxChar=null;
for(var chars in obj){
if(max<obj[chars]){
max=obj[chars];
maxChar=chars;
}
}
console.log("出现最多的是"+maxChar+"总共出现"+max+"次");
</script>
标签:++ java var log hello asc max type null
原文地址:http://www.cnblogs.com/hngdlxy143/p/6880400.html