Solución
solution.tsTypeScript
function groupByLength(words: string[]): Record<number, string[]> {
if (!words.length) return {}
const map = new Map<string, string[]>();
for(const word of words) {
const wLength = word.length;
const currVals = map.get(wLength.toString()) || []
map.set(wLength.toString(), [...currVals, word])
}
// Escribe tu solución aquí
return Object.fromEntries(map);
}
// No modificar: necesario para evaluar el resultado.
export { groupByLength };0respuestas