Exercise · Map, Set and JSON · lesson 8 of 9
Exercise: no duplicates
Write a function function unique(words) that returns a new array: the words from words without repeats. Words that differ only in letter case count as one word. The spelling that came first is kept, in the place where it first appears.
unique(["a", "b", "a", "c", "b"])→["a", "b", "c"]unique(["Cat", "dog", "cat", "DOG"])→["Cat", "dog"]unique([])→[]
Constraints: words holds 0 to 10 words of Latin letters; for an empty array the result is []; the array words itself must not change.
Do not add extra imports unless the task says so explicitly.
Subscribe to take the course
The course is free. Sign in with Telegram and subscribe to the channel to open every lesson.