ga-wdi-exercises / project1

[project] GA- Project 1
3 stars 75 forks source link

issue with line 26 of my JS #240

Closed brendaneamon closed 8 years ago

brendaneamon commented 8 years ago

I tried to change my program so that the game would only continue as long as there were still flash cards left to cycle through, so I removed the variable i that I had originally included.

I expected the game to continue normally, as it had before. Instead, the value of my array at [0][0] is coming back as undefined in my displayWord() function.

My repo link is https://github.com/brendaneamon/project1-flashcards and my question is about line 26, and its implications on everything I've written since my last commit.

RobertAKARobin commented 8 years ago

Is it because you're shifting too many things off of that array? Remember: .shift() modifies the array itself. So if you do deckOfCards.shift() 52 times, it'll become an empty array.

RobertAKARobin commented 8 years ago

To diagnose, I'd recommend putting a debugger right inside your while loop so that your script pauses during every loop, letting you see what the value of vocabWords is at each point in time, and how it changes.

brendaneamon commented 8 years ago

OK, will try that!