Been thinking about it. Not entirely sure how to do it without generating my own intermediate array shifting things out of it, then unshifting them back into it. Seems terribly messy so I'm hoping that's not the answer. My awful answer is below.
removeWithoutCopy : function(arr, item) {
var intermediate = [];
while (arr.length > 0) {
var result = arr.shift()
if (result !== item) {
intermediate.unshift(result);
}
}
while (intermediate.length > 0) {
arr.unshift(intermediate.shift());
}
return arr;
},
Been thinking about it. Not entirely sure how to do it without generating my own intermediate array shifting things out of it, then unshifting them back into it. Seems terribly messy so I'm hoping that's not the answer. My awful answer is below.