DEV Community

Discussion on: Removing duplicates from an array

lukaszahradnik profile image
Lukáš Zahradník

I think it's fine and that is still pure. It creates new object, fills it with entries and returns, no side effects involved.

Also, in your solution you are "mutating" object map (which I think it's also fine)

Thread Thread
assuncaocharles profile image
Charles Assunção

Not really, I am keeping the same entry as the original array and not converting it to a string, what can be even trickier if your elements is an object or another thing. Returning an array of strings you are not preserving the data.

Thread Thread
lukaszahradnik profile image
Lukáš Zahradník

I thought you meant the way I'm updating accumulator.

I agree with you. I pointed out in my first comment, that there is an issue with returning string representation and not original data.