for (var i = playlistIndex.length - 1; i >= 0; i--) That's not how we do for loops. for (var i = 0, length = playlistIndex.length; i < length; i++){ Including 1 as the second parameter in splice is the same as not including the second parameter at all. playlist.splice(playlistIndex[i],...