This is the Code I have written to count
var name = "Interesting";
var letter_count = {};
for(var i in name){
if (!(i in letter_count)){
letter_count[i] = 1;
}
else {
letter_count[i] += 1;
}
}
console.log(letter_count);
expected output:
{ i: 2, n:2, t:2, e:2, r:1 s:1, g:1 }
irepresents the index of the letter inname, not the letter itself