← Back to challenges

Remove Duplicates from an Array

JavaScriptHardarraysstringsinterviewlanguage_fundamentals

Instructions

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.
javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Trace That Matrix