let str = 'I am excited to join a new company';
function findOccurrencesOfEveryChar(string) {
const obj = new Map();
for (const char of string.toLowerCase()) {
if (/[a-z]/.test(char)) { // Only count alphabetic characters
obj.set(char, (obj.get(char) || 0) + 1);
}
}
return obj;
}
console.log(findOccurrencesOfEveryChar(str));