← Back to challenges

Purge and Organize

JavaScriptHardarraysdata_structuressortingnumbersloops

Instructions

Given an array of numbers, write a function that returns an array that...

  1. Has all duplicate elements removed.
  2. Is sorted from least to greatest value.

Examples

uniqueSort([1, 2, 4, 3]) ➞ [1, 2, 3, 4]

uniqueSort([1, 4, 4, 4, 4, 4, 3, 2, 1, 2]) ➞ [1, 2, 3, 4]

uniqueSort([6, 7, 3, 2, 1]) ➞ [1, 2, 3, 6, 7]

Notes

N/A

javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Xs and Os, Nobody Knows