Remove Duplicates from an Array

Published by kochug in

Create a method that takes an array of strings or integers, 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 integers.
  • Tests are case sensitive.
  • Each array item is unique.
Watch a quick demo on how Edabit works.