<HTML>
<body>
</body>
<script>
function filterRangeInPlace(arr, min, max){
arr.forEach(function(item, index, arr){
if(item >= min || item > max){
//alert(`event happened at ${index} value is ${item}`);
arr.splice(index, 1);
}
});
return arr;
}
let arr = [5 ,3, 8, 1];
arr = filterRangeInPlace(arr, 1,4);
alert(arr);
</script>
</HTML>
<body>
</body>
<script>
function filterRangeInPlace(arr, min, max){
arr.forEach(function(item, index, arr){
if(item >= min || item > max){
//alert(`event happened at ${index} value is ${item}`);
arr.splice(index, 1);
}
});
return arr;
}
let arr = [5 ,3, 8, 1];
arr = filterRangeInPlace(arr, 1,4);
alert(arr);
</script>
</HTML>
댓글
댓글 쓰기