From 889068a09f285bc67a6fe8c5762c341bd303def8 Mon Sep 17 00:00:00 2001 From: Roman Shterenzon Date: Wed, 23 Sep 2020 11:43:45 +0300 Subject: [PATCH] Don't modify the original container while doing removeCard If card.container == cards, then cards.length will change. Ensure that we're iterating over a copy. --- cards.js | 1 + 1 file changed, 1 insertion(+) diff --git a/cards.js b/cards.js index 387191c..ac523ef 100644 --- a/cards.js +++ b/cards.js @@ -182,6 +182,7 @@ var cards = (function() { }, addCards: function(cards) { + cards = cards.slice(); for (var i = 0; i < cards.length; i++) { var card = cards[i]; if (card.container) {