Score in game causes error code

Score in game causes error code, even though same code for score works in previous level/lessons

Link to the project or level:
What I expect to happen: score shows during game play
What actually happens:* ERROR: Line: 12: TypeError: Cannot read property ‘toString’ of undefined
What I’ve (& two other students) tried: copy/paste code from working score game, build code again, switching browsers, logoff/login

Lines 5 & 39 both try to declare the variable “score”. Try removing the var block from line 39 and only having it say “score=score+1” (without the “var”).

That should fix the error!

Best of luck!


Line 39: score is already defined

You don’t want to define a variable twice, because the code won’t know which variable to use, thus the error. if you remove the var on line 39, it should work.

The students were able to correct the errors and successfully get the program to work.
Thank you for the help!
I GREATLY appreciate your help!! :smiley:

1 Like