Closed Jlarranaga closed 9 months ago
The error says it can't tell what the cCard is, are there any times where that property is being cleared out or the .face
is being removed?
I do change the variable. Let me take a look and see what I can find. Thank you!
OK, find out where it's being changed, and then think about where you need to add it back before looking for it again
So i found i keep getting undefined pushed into my array after a war game. I looked all over and changed code and thought I fixed it. It keeps coming up after gameplay for a while. I even commented out a section of code and changed how the game plays where I thought the issue was coming from but it didnt work
So right now both decks have 29 cards out of a 52 card deck. Somewhere, I am adding more cards in...
Whats better? for loop? or for each loop?
to go through an array items and move those array items from one to another.
I'd recommend trying forEach to start, unless you can't get that to work that way.
is this for loop working right?
for(i=0; i<=1; i++){ //TODO chaned to 2 and commented out. Will this solve issue? NO pWarCards.push(pCards[i]) pCards.splice(i,1) cWarCards.push(cCards[i]) cCards.splice(i,1) }
I want to add 2 items to this array and remove 2 items from another. right?
What's the problem you're trying to solve?
Randomly, I get errors saying it can't read the card class property 'face' and it only happens after playing several rounds. It's not just one spot it comes up random where it says it can't read the property 'face' but reads it fine in other areas of the code.
Post any code you think might be relevant (one fenced block per file)
If you see an error message, post it here. If you don't, what unexpected behavior are you seeing?
What is your best guess as to the source of the problem?
Find out where face comes from and go from there
What things have you already tried to solve the problem?
using console.log to debug and Google Chrome debugger and thats how I found its popping up randomly
Paste a link to your repository here
https://github.com/Jlarranaga/Project1-WAR