Closed brendaneamon closed 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.
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.
OK, will try that!
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.