I have a function which groups anagrams together
function groupAnagrams(strs) {
let result = {};
for (let word of strs) {
let cleansed = word.split("").sort().join("");
if (result[cleansed]) {
result[cleansed].push(word);
} else {
result[cleansed] = [word];
}
}
console.log(Object.values(result));
return Object.values(result);
}
it prints the results in the following format
[ [ 'abc', 'bac', 'cba' ], [ 'fun', 'fun', 'unf' ], [ 'hello' ] ]
However I would like the output to look like the following
abc, bac, cba
fun, fun, unf
hello
How can I achieve this?