Explorer
Node.js

Write a function `uniqueValues(arr)` that returns an array of unique values using a Set.

Problem Statement

Write a function `uniqueValues(arr)` that returns an array of unique values using a Set.

Complexity

Time Complexity: -

Space Complexity: -

Hints

šŸ’” Hint 1: A Set automatically removes duplicate values. šŸ’” Hint 2: You can convert an array to a Set and back: [...new Set(arr)]. šŸ’” Hint 3: return [...new Set(arr)]; āœ… Solution: ```javascript function uniqueValues(arr) { return [...new Set(arr)]; } ```

Map and Set Basics

Easy
Write a function `uniqueValues(arr)` that returns an array of unique values using a Set.
Editor
Loading Editor...
Evaluate code
Output:Click "Run" above to execute and verify your code here.
[1,2,3,4]