function solution(s){
let answer={};
let ary = s.split("")
ary.forEach(x => {
answer[x] = (answer[x] || 0)+1
});
return answer;
}
let str="KKHSSSSSSSE";
console.log(solution(str));
if(answer[x]){ answer[x] +=1 }else{ answer[x] = 0+1; }
<forEach> ary.forEach(x => { answer[x] = (answer[x] || 0)+1 });
<reduce> ary.reduce((acc, curt)=>{ acc[curt] = (acc[curt] || 0)+1 return acc }, {})