Whiteboard 002 - Agrupando anagramas
2019-10-23T00:00:00.000Z
Tienes un arreglo de palabras.
const agrupaAnagramas = (arr) {
groups = {}
for (word in arr){
if(groups[arr[word].split('').sort().join('')] == undefined){
groups[arr[word].split('').sort().join('')] = [arr[word]];
}
else{
groups[arr[word].split('').sort().join('')].push(arr[word])
}
}
return Object.values(groups)
}
🐬