I want to compare the elements in an array, eliminate the duplicates using map().. example: array = [1,2,1,3,2]=> finalArray = [1,2,3]
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.
I want to compare the elements in an array, eliminate the duplicates using map().. example: array = [1,2,1,3,2]=> finalArray = [1,2,3]
For further actions, you may consider blocking this person and/or reporting abuse
NicolasBiondini -
Pavel Keyzik -
Richard Rembert -
Dillion Megida -
Discussion (4)
This is how I'd do it in Python:
There's probably a better way but adding each item to a map (dict) is enough, as there can't be repeated keys; then pass every key to an array.
Ok..
I don't speak python for now. Am a newbie in JavaScript trying to work on that task.
Thanks for your response...๐
Well, I'm not fluent on JS either but I don't think they're so different at tackling this problem :)
Use sets that would make it easy