[JavaScript] Elegant one line solution using sort and reduce (with explanation)
Unfortunately, due use of .sort() method time complexity is \u0398(n^2) at best\n\njavascript\nconst maxProduct = (nums) => nums.sort((a, b) => a - b).splice(-2
Unfortunately, due use of `.sort()` method time complexity is \u0398(n^2) at best\n\n```javascript\nconst maxProduct = (nums) => nums.sort((a, b) => a - b).splice(-2).reduce((i, j) => (i-1)*(j-1))\n```\n\nExplanation:\n1. `.sort((a, b) => a - b)` - sort array elements in ascending order (by default it sorts elements alphabetically)\n2. `.splice(-2)` - take two last elements\n3. `.reduce((i, j) => (i-1)*(j-1))` - since there are only two elements we are not accumulating anything and simply calculating the result using both numbers from the array
['JavaScript']