Remove Duplicates from an Array

Published by Николай in

Create a function that takes an array of items, removes all duplicate items and returns a new array in the same sequential order as the old array (minus duplicates).

Examples

RemoveDups([1, 0, 1, 0]) ➞ [1, 0]

RemoveDups(["The", "big", "cat"]) ➞ ["The", "big", "cat"]

RemoveDups(["John", "Taylor", "John"]) ➞ ["John", "Taylor"]

Notes

  • Tests contain arrays with both strings and numbers.
  • Tests are case sensitive.
  • Each array item is unique.
Watch a quick demo on how Edabit works.