Remove duplicates
EasyArrays · JavaScript
The task
Write removeDuplicates(arr) that returns a new array with each value appearing only once.
Keep the first occurrence of each value, in the original order.
Examples
- removeDuplicates([1, 2, 2, 3, 1]) returns [1,2,3]
Your code runs in your browser, in a separate worker, and is never sent to us. Edit the function, then press Run tests. Your work is saved here as you type.
JavaScriptCtrl or Cmd + Enter to run