array = ['dog','dog','dog','cat','cat', 'mouse','egg','egg']
newArray = ['dog','cat','mouse','egg']: expected array.
thank you.
i tried to run with map and compre the word to the other words at differet index.
array = ['dog','dog','dog','cat','cat', 'mouse','egg','egg']
newArray = ['dog','cat','mouse','egg']: expected array.
thank you.
i tried to run with map and compre the word to the other words at differet index.
Your second array isn't sorted but...
To sort the array use: array.sort()
To get unique values: Array.from(new Set(array))
Also do not name your array array.
This was already answered here: How to get unique values in an array