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

Aim shooter

I can’t find the error in my code. There’s supposed to be 5 boxes moving but none of them are moving and is just a blank screen. https://code.sololearn.com/W0v3Op5P5vsZ/?ref=app

19th Jul 2022, 4:36 PM
Junior
Junior - avatar
9 Answers
+ 2
Your Mom Read the message error. It tells a lot. Then read about getElementById method. You're trying to use in JS a reference only present in HTML.
19th Jul 2022, 5:00 PM
Emerson Prado
Emerson Prado - avatar
+ 2
Please don't delete the code. When you do so then all the comments posted become useless.
22nd Jul 2022, 6:22 AM
Chris Coder
Chris Coder - avatar
+ 1
In general, the code is too confusing and repetitive, making it difficult to debug. Some questions: 1. Line 4 seems invalid. What is its purpose? let time = document.getElementById("timer").innerHTML = timer--; 2. There are 5 identical functions for the boxes. Why are them separated, instead of a single one with box as a parameter? 3. How is the code supposed to behave? My advice is to take a step back and think the logic. Maybe it just got too far before being well structured, and this makes it hard for you.
19th Jul 2022, 11:38 PM
Emerson Prado
Emerson Prado - avatar
0
What JS reference is that?
19th Jul 2022, 5:03 PM
Junior
Junior - avatar
19th Jul 2022, 6:05 PM
Junior
Junior - avatar
0
Nevermind i figured it out
19th Jul 2022, 6:06 PM
Junior
Junior - avatar
19th Jul 2022, 6:17 PM
Junior
Junior - avatar
0
Okay, so ye i tried re doing it and still not working for some reaosn https://code.sololearn.com/W0v3Op5P5vsZ/?ref=app
20th Jul 2022, 1:07 AM
Junior
Junior - avatar
0
Your Mom I still think a step back would be the best now. I'm struggling a lot to follow the logic, and can't figure what the code should do. Can you explain how this should work?
20th Jul 2022, 3:30 AM
Emerson Prado
Emerson Prado - avatar