DEV Community

Discussion on: How to lose a Job in 10 minutes

Collapse
 
cathodion profile image
Dustin King

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?

Collapse
 
albinotonnina profile image
Albino Tonnina

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 :)