I encountered an unexpected issue...
// ticketList is the id of an html table
console.log("ticketList.rows.length before: " + ticketList.rows.length);
for (i= 1; i < ticketList.rows.length; i++) {
ticketList.rows[i].remove();
console.log(`ticket ${i - 1} removed`);
}
// additional code that functions correctly
console.log("ticketList.rows.length after: " + ticketList.rows.length);
Here is the output in the console:
ticketList.rows.length before: 13
ticket 0 removed
ticket 1 removed
ticket 2 removed
ticket 3 removed
ticket 4 removed
ticket 5 removed
ticketList.rows.length after: 19
The initial count of 13 seems correct. Why does it stop at 6 iterations instead of removing twelve elements as expected?
I attempted to manually set the end value in the for-loop and received this error:
Cannot read properties of undefined (reading 'remove')