I will be happy if someone could help me with my problem :
I'm trying to delete the current max number form the nums Array and I couldn't get it done.
function getNthLargestNum(nums, nth) {
debugger;
var maxNums = [];
for (var i = 0; i < nth; i++) {
var nthMax = 0;
var maxTemp = 0;
for (var j = 0; j < nums.length; j++) {
if (maxTemp < nums[j]) {
maxTemp = nums[j];
//splice();
}
}
nums.splice(maxTemp, maxTemp[j]);
maxNums.push(maxTemp);
}
nthMax = maxTemp;
return nthMax;
}
var nums = [4, 5, 6, 8, 40, 60, 54, 32, 8, 1];
//var nums = [4 , 5 , 6 , 8 , 40 , 3 , 8 , 1];
var res = getNthLargestNum(nums, 3);
``
console.log(res);