js practice for a junior-mid (Me), chatgpt called it pipelines or some shit
what are experienced people's opinion on chaining operations like this?
const wordProcessor = (w) => {
return Object.entries(
w.reduce((acc, e) =>
((acc[e.length] ??= [])
.push(e),acc),{}
)
)
.map(e => e[1].sort()).flat()
}
const words = ["hi", "hello", "hey", "a", "to", "cat", "go", "no"];
console.log(wordProcessor(words))
const expected = ["a", "go", "hi", "no", "to", "cat", "hey", "hello"]