Solución
solution.tsTypeScript
function groupByFirstLetter(words: string[]): Record<string, string[]> {
const result = new Map();
words.forEach(word => {
const firstLetter = word[0].toLowerCase();
if(!result.get(firstLetter)) result.set(firstLetter, []);
result.set(firstLetter, [...result.get(firstLetter), word])
})
return {...Object.fromEntries(result)};
}
// No modificar: necesario para evaluar el resultado.
export { groupByFirstLetter };0respuestas