-2
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.

flyingfox
  • 13,414
  • 3
  • 24
  • 39

1 Answers1

0

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