I've been learning to code using an online Udemy course. I applied what I learned to building my first Node/Mongo/Express web app, a trivia game, but I'm stumped trying to solve this problem.Basically, the game asks you a series of trivia questions pulled at random from a (Mongo) database. You're asked ten questions and it gives you a score out of 10 at the end. When you submit an answer it posts it, compares it to the possible correct answer, and tells you that you got it right or wrong and shows you the next question.I thought things were going well but noticed today that when I started out it had me at question two. It turns out that the variables tracking the question number and the score are not resetting. So if I start a game in one browser window, then start another browser window and play the game, the variables (questionCount, score) pick up with whatever I left things at before.I think part of the reason I'm having trouble researching this is because I am not sure of what I should be searching for. I feel like there's something simple to do with the scope of my variables but I just keep coding around in circles.
Submitted August 02, 2017 at 02:47AM by iamsynecdoche
No comments:
Post a Comment