I have created sample quiz project.But score is not counting.what is wrong in my code | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

I have created sample quiz project.But score is not counting.what is wrong in my code

https://code.sololearn.com/W0RC9AuGi871/?ref=app

17th Mar 2023, 1:40 PM
Susheela
Susheela - avatar
10 Answers
18th Mar 2023, 12:31 AM
JaScript
JaScript - avatar
+ 4
Additional to Lisa‘s hint will be needed to optimize your code because of infinite score‘s addition.
17th Mar 2023, 2:18 PM
JaScript
JaScript - avatar
+ 3
When ever you try the correct answers of a question the score still increments, find a way to increment the score just once for the first time you tap the correct answer.
17th Mar 2023, 2:37 PM
Yasin Rahnaward
Yasin Rahnaward - avatar
+ 2
You keep resetting the score to 0 whenever the option() function is called (Javascript, line 2)
17th Mar 2023, 1:42 PM
Lisa
Lisa - avatar
18th Mar 2023, 1:13 AM
Yasin Rahnaward
Yasin Rahnaward - avatar
+ 2
Thank you so much to all 😊
18th Mar 2023, 4:24 AM
Susheela
Susheela - avatar
+ 1
Hi Susheela In js file move the var score=0; variable to outside of the function. try to add a answer object with correct value of each question and use them in condition to prevent from score increments every time when user click on correct answers.
17th Mar 2023, 1:54 PM
Yasin Rahnaward
Yasin Rahnaward - avatar
+ 1
Yasin rahnaward Tq for this code But i don't how to add answer object
17th Mar 2023, 2:33 PM
Susheela
Susheela - avatar
+ 1
I created a sample code. Select "7" and "skyblue" and press answer button to get the score. https://www.sololearn.com/compiler-playground/WD9pEHV8EM47
17th Mar 2023, 3:25 PM
Shugo
Shugo - avatar
+ 1
Tq Lisa But how to i reset the score to 0
17th Mar 2023, 3:55 PM
Susheela
Susheela - avatar