My code includes an if statement inside a for loop that iterates over the entire array and displays its elements:
for (var i = 0; i < txtA.length; i++) {
txtA[i].update();
txtA[i].show();
if (txtA[i].y == height) {
txtA.pop();
console.log(txtA.length);
}
}
The issue arises when the if statement evaluates to true, causing all elements in the array to be removed. Can someone provide guidance on how to prevent this from happening?