Quantcast
Channel: How to convert Set to Array? - Stack Overflow
Viewing all articles
Browse latest Browse all 11

Answer by Drashti Trivedi for How to convert Set to Array?

$
0
0

I would prefer to start with removing duplications from an array and then try to sort.Return the 1st element from new array.

    function processData(myArray) {        var s = new Set(myArray);        var arr = [...s];        return arr.sort((a,b) => b-a)[1];    }    console.log(processData([2,3,6,6,5]);

Viewing all articles
Browse latest Browse all 11

Trending Articles