str.split('').forEach((char) => {
if (charMap[char]) {
charMap[char]++; // This will add 1
} else { // If no letter has been found yet
charMap[char] = 1;
}
});
}
and the function returns undefined unless I return charMap.
This seems like a slight mistake.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I've run this snippet :
function maxCharacter(str) {
const charMap = {};
str.split('').forEach((char) => {
if (charMap[char]) {
charMap[char]++; // This will add 1
} else { // If no letter has been found yet
charMap[char] = 1;
}
});
}
and the function returns undefined unless I return charMap.
This seems like a slight mistake.