Javascript Array removeNegativity(arr)
// remove negatives function removeNegativity(arr) { var numNegatives = 0; for (var i = 0; i < arr.length; i++) { if (arr[i] >= 0) { arr[i - numNegatives] = arr[i];/*w w w .ja va2 s. c om*/ } else { numNegatives++; } } arr.length -= numNegatives; return arr; }