Solución

@jatrujilloch1_c800f92b
·hace 3dTypeScript
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
Respuestas
0

Aún no hay respuestas

¡Sé el primero en responder!

Escribir un comentario

Recuerda ser amable. Estás comentando la solución de otra persona. Comparte tu perspectiva de forma constructiva y respetuosa.

Debes iniciar sesión para publicar un comentario.
Markdown