Is it a misuse of reduce to modify acc (because, ideally in functional programming, things are immutable), or does returning acc from the reducer function mitigate that?
Hey! Thanks!
I would go for the mitigation :P
const groupCitiesByRotatedNames = cities => newArray
I guess you could return always a clone of acc? For the purpose of the article, I would not give too much importance to this to be honest :)
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Is it a misuse of reduce to modify acc (because, ideally in functional programming, things are immutable), or does returning acc from the reducer function mitigate that?
Hey! Thanks!
I would go for the mitigation :P
const groupCitiesByRotatedNames = cities => newArray
I guess you could return always a clone of acc? For the purpose of the article, I would not give too much importance to this to be honest :)