1var sortEvenOdd = function (nums) {2let odd = nums.filter((num, i, arr) => i % 2 != 0).sort((a, b) => b - a); //decreasing order3let even = nums.filter((num, i, arr) => i % 2 == 0).sort((a, b) => a - b); //increasing order4let x = 0,5y = 0;67nums.forEach((num, i, nums) => {8nums[i] = i % 2 == 0 ? even[x++] : odd[y++]; //refilling the array9});10return nums;11};