I'm struggling with removing/unsetting a specific array in Javascript. I attempted to use the splice method, but it's not giving me the desired result. It seems like there's something that I'm overlooking here.
var arr = [12, 3, 150];
var min = 100;
var max = 200
for (var key2 in arr) {
if (min > arr[key2] || arr[key2] >= max) {
arr.splice(key2, 1);
}
}
console.log(arr);
The current output of the code is: [ 3, 150 ]
However, my expected output is: [150]