Skip to content
Advertisement

Javascript array sort and unique

I have a JavaScript array like this:

JavaScript

I need the array elements to be unique and sorted:

JavaScript

Even though the members of array look like integers, they’re not integers, since I have already converted each to be string:

JavaScript

Is there any way to do all of these tasks in JavaScript?

Advertisement

Answer

This is actually very simple. It is much easier to find unique values, if the values are sorted first:

JavaScript
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement