+ 1
Why isn't this variable being defined?
I'm trying to make a simple guess the number game in javascript but my random number variable is getting an error saying it's not defined, https://code.sololearn.com/W945a2VVI4rc/#html is there a syntax error I'm missing? edit:fixed link, sorry
3 Respuestas
+ 4
If you delete the while loop it will work just fine, or in the last if statement is the code GuessGame = false. If you place that outside that while loop it will also work.
The best thing to do is probably to delete the while loop though.
+ 3
Randomise a number when the window loads in a separate function and when they guessed the number you call that function again
+ 1
Okay thanks, the while loop was the first thing that came to mind because I want this program to be able to loop back so people can play more than one time without rerunning the code, do you have any better solutions?