Sort by

recency

|

1468 Discussions

|

  • + 0 comments

    function getSecondLargest(nums) { // Complete the function let sortedNums = Array.from(new Set(nums)).sort((a, b) => (b-a));

    //sorted nums;
    return sortedNums[1];
    

    }

  • + 0 comments
    function getSecondLargest(nums) {
        const uniqueNums = nums.filter((value, idx, self)=> self.indexOf(value) === idx);
        return uniqueNums.sort((a,b)=>b-a)[1];
    }
    
  • + 0 comments

    THIS IS MINE

    function getSecondLargest(nums) {
        return Array.from(new Set(nums)).sort((a, b) => b - a) [1];
    }
    
  • + 2 comments
    function getSecondLargest(nums) {
        const uniqueNums = [...new Set(nums)];
        uniqueNums.sort((a, b) => b - a);
        return uniqueNums[1];
    }
    
  • + 0 comments
    function getSecondLargest(nums) {
        return (Array.from(new Set(nums)).sort((a,b) => a - b).reverse())[1]
    }