JavaScript Functions(Please Help) | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

JavaScript Functions(Please Help)

I am working on a quiz game and I am having an error message come up. This is my quiz game https://code.sololearn.com/WbuqxDa17ru7/# and the message is TypeError: Cannot set property 'innerHTML' of null at addQuestion (<anonymous>:108:31) at generateQuiz (<anonymous>:134:4) at start (<anonymous>:74:4) at HTMLButtonElement.onclick I have no idea how to fix this. Please help anyone. Thank you, -Trevor

31st Aug 2021, 1:07 AM
Trevor Flynn
3 Answers
31st Aug 2021, 1:33 AM
Ipang
+ 1
im going to try my best here to help you. base on Ipang post, it looks like your javascript is running before the elements are created. i would imagine it could help if you moved your html code to the top. i would also imagine you could move your css to the css tab and your javascript to the javascript tab to make the html a little bit easier to read.
31st Aug 2021, 3:05 AM
you are smart. you are brave.
you are smart. you are brave. - avatar
+ 1
when i moved you html to the top, all your questioned showed. i then got an error message when i clicked on the submit button. when i moved the submitbut function i got another error message and kind of gave up. second error message. ReferenceError: Can't find variable: showResults at Line: -37
31st Aug 2021, 3:13 AM
you are smart. you are brave.
you are smart. you are brave. - avatar