Help me pls ! | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Help me pls !

In this code I am making kinda quiz game.But the problem is in the Javascript side.When you guessed first one correctly and jump to the second one,whatever you guess(even true) the output is always "Wrong !".You will see the problem in this code.Which thing I have written wrong?Help me pls. https://code.sololearn.com/Wob4Tz21PIIb/?ref=app

29th Aug 2019, 7:05 PM
Aziz Mandıracı
Aziz Mandıracı - avatar
6 Answers
+ 1
Line 5 and line 17 both are adding click event listener to the same button. When the first question is done, the first event listener is not removed and is still effective. One of the way is to use jQuery off function to remove the click event listeners each time the question is answered correctly. https://code.sololearn.com/Wm032MywK3IB/?ref=app
29th Aug 2019, 8:50 PM
Gordon
Gordon - avatar
+ 2
Tbh I'm not sure, ur using jquery right ? 🤔🤔🤔 Ps. I suggest you tidy up your code a bit. It looks somewhat messy on mobile. No offence man Really like you code though 😉
29th Aug 2019, 7:44 PM
Minerals2016
Minerals2016 - avatar
+ 2
Yeah I know, sorry abt that. It looks like it should work but I have the same question. I haven't used jquery yet so I'm somewhat clueless. Good luck though 😉👍
29th Aug 2019, 8:21 PM
Minerals2016
Minerals2016 - avatar
+ 2
Interesting way to use flags in if. By the way, you may want to read this JavaScript code styling guide: https://www.sololearn.com/post/122691/?ref=app
30th Aug 2019, 12:41 AM
Gordon
Gordon - avatar
+ 1
Minerals2016 tidying up... is not solution but thank u anyways;)
29th Aug 2019, 8:13 PM
Aziz Mandıracı
Aziz Mandıracı - avatar
0
@Gordon thanks for code.I appreciated for that.I make little changes on this code .Final code: https://code.sololearn.com/WiYSCmNOg4x1/?ref=app
29th Aug 2019, 9:42 PM
Aziz Mandıracı
Aziz Mandıracı - avatar