Skip to content
RED SAGSkills
hard20 pts · first answer countsarraysdebuggingjavascript

Removing items while looping forward

This code should remove every cancelled order but leaves one behind for [c, c, ok] (c = cancelled). Why?

for (let i = 0; i < orders.length; i++) {
  if (orders[i].cancelled) orders.splice(i, 1)
}
Choose one answer

Discussion 0

Join free to post in the discussion.

Related questions