This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//remove n number of elements from an array, largest to smallest | |
function removeLargest(arr,n){ | |
for (var i = 0; i < n; i ++){ | |
var sorted = Math.max.apply(null, arr); | |
//run through array, funding largest | |
var rem = arr.splice(arr.indexOf(sorted),1); | |
//remove largest | |
} console.log(arr); | |
} |