Skip to content

Latest commit

 

History

History
38 lines (24 loc) · 1.04 KB

File metadata and controls

38 lines (24 loc) · 1.04 KB

Unique Array

Problem

https://www.greatfrontend.com/questions/javascript/unique-array

Problem Description

Implement a function uniqueArray that takes in an array and returns a duplicate-free version of the array where only the first occurrence of each element is kept. The order of result values is determined by the order they occur in the array.

Examples

uniqueArray([1, 2, 3]); // [1, 2, 3]
uniqueArray([1, 1, 2]); // [1, 2]
uniqueArray([2, 1, 2]); // [2, 1]

Solution

Unique Array