Rates TodayNIFTY25,670-0.83%SENSEX83,630.7-0.83%Gold 24K ₹11,320.24/g down186.46Silver ₹134.77/g down2.72
InsightforGeeks

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.

JavaScript

Stuck?