QuizNot attempted
Spot the bug: comparing pages to items
1–4 to choose, Enter to submit
Show answer & explanation
Correct answer:
- Only when currentPage reaches 95, so it keeps "loading" empty pages long after all rows are shown
- The condition compares a page count with a row count.
- After page 5 every row is shown, but
5 < 95, so each intersection schedules another one-second load of an empty slice, and since re-observing a visible element fires straight away it loops while the bottom is on screen. - Derive the end in one unit:
hasMore = displayData.length < data.length(orcurrentPage < Math.ceil(total / perPage)), and stop observing when it is false. - Not after page 5: that is what the author meant, not what the code checks.
- Not after page 4: the bug loads too much, not too little.
- Not immediately:
1 < 95is true.