0
[Solved] Help needed with a javascript bug. Color Guessing Game.
My program is a color choosing game, I randomly set a color per div and randomly choose one . As you play , some times the chosen color (the one you're supposed to find) , isn't one of the colors in the div. Then none of the answers are correct . https://code.sololearn.com/W3BpYFPY42FJ/?ref=app
7 Respuestas
+ 2
The problem only occurs when chosenN equals zero.
You can add +1 to line 28: var chosenN = Math.floor(Math.random()*6+1);
This will ensure you get a random number from 1 to 6 instead of a number from 0 to 5.
I didn't correct your code, I just logged chosenN to the console and numbered each div. This was done for visual effect.
https://code.sololearn.com/WrmuDT0I2LrA
+ 2
Thanks Vasiliy ,Brain & Bones and ODLNT , you have been a great help , thanks for the help and the valuable suggestions.
+ 1
You're welcome 😊
+ 1
Thanks Vasiliy , it's edited now 👍
0
Great code, works well.
I did not find any color mismatches, I guessed most of them. ☺️
If we add the statistics of responses, then in general it would be great.
0
I see your problem, why dont you add the six colors of that round into an array and then the color you are to guess can be randomly pick from that array