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?
for extra context, this pipeline or whatever this style is called used to be posted on this general some time ago, and I really liked it, and in this specific exercise, just wanted to take it a bit further, this is shorthanding everything except the return function. obviously the readability is not its strength but if the syntax is there might as well use it, what do you think?
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"]