Hi, I think your exercise it’s incomplete, talking about the error you should do something like this:
for (let char of str) {
maxChar[char]
}
But that doesn’t solve the exercise, because you not counting the chars and actually maxChar should be the value that you return, that means that you need another variable, where you will be storing the current value, something like this:
function maxChar(str: string) {
let chars = {}
let maxChar = ‘’
for (let char of str){
chars[char] = chars[char] + 1 || 1
if (maxChar === ‘’ || chars[char] > chars[maxChar]) {
maxChar = char
}
}
return maxChar
}
Hope it helps, Greetings.
Thanks for the answer but problem is still there. I tried many other answers from different sites but it always looks like that in the end.
I tried and it’s working, mmm where are you compiling your program? It’s the Codecademy in-app or witch one?
I do it in Gitpod. I think that it would work if I wasn’t using TypseScript.