console.clear(); var arr = [1,2,3,4,5,6,7]; for(var i = 0; i < arr.length; ){ if ( arr[i] > 4) arr.splice(i, 1); else i++ } console.log(arr);