+ 4
Why it doesn't work??
Its a simple clicker game but idk why it doesnt work, pls help (It only works on PC and I want to make it work on mobile too) https://code.sololearn.com/W9P3X1AaDkCh/?ref=app
11 Réponses
+ 5
I formatted your code and fixed the events – I am not sure if it actually works as you intended it, but I think the basics work now.
I added a little summary in the JS tab.
https://code.sololearn.com/Ww13W4uUPGbc/?ref=app
+ 5
Your code is a little hard to read but I noticed 3 issues:
You can only get the html element, e.g. that clicker button, once the body is fully loaded. This means for example, that
const clickerButton = document.getElementById('clicker');
should be assigned _after_ the window is loaded.
addEventListener() is a method of an html element. So if you want to add the event to the clicker, it should be
clickerButton.addEventListener(...)
There are some mismatched () and {}. Example in line 13:
clickerButton.addEventListener('click"), () => ....)
The syntax should be:
clickerButton.addEventListener('click', () => {...});
+ 2
Some interpreters, like mainstream browsers, try hard to get around code errors. The ACID tests measure, in great part, exactly this ability. So a code that fails can work in a browser.
I recommend always check your code with validators like the w3c online service:
https://validator.w3.org/
+ 1
Ohhh thanks
+ 1
I'll try to fix it
+ 1
The thing is that in PC it works, and when I tried it in mobile, it gave a lot of errors
+ 1
Thanks Emerson Prado
+ 1
Lisa I tried to change all the addEventListeners to clickerButton.addEventListener
But it doesnt work idk why
+ 1
I will have a look at it later tonight :)
+ 1
Thank you so much :)))
+ 1
Thank you soooooooo much Lisa <3