0
What is wrong with this function()?
I tried to write a simple guessing game to practice the 'if else' conditional statements: https://code.sololearn.com/W8u1VoX92RR6/#html I can't figure out why the function submit() only seems to increment the variable 'score' the first time (score++;). And it doesn't increment the variable 'answer' (answer++;) at all. EDIT: the code works now!
2 Respostas
+ 5
You should globally declare your variables, (AKA: on top of script and not inside function because the get redeclared and reseted) [PS: Try adding a little randomness in it ;) ]
+ 1
Yes! it works! thanks Valen H, now I will try and make the number random. I just learned how to do that