0
Whats wrong in this code? (JS)
Whats wrong there? I can't find whats wrong. https://code.sololearn.com/WV89yXsY98en/ JS, line: 5 (Text is in german)
4 Antworten
+ 2
The problem is than the i var in time function is always 0 at start of any time() call then though you inctement it (its temporary and not global). Inside time() uoua will get a reference to button and if i<1 you remove it BUT its always the case then you will access to a null refetence to button (returned by getElementById) and, without checks, you try to access to a field of null object raising an exception
+ 2
you have to declare let i = 0; outside the time function. otherwise it will always be 0.
+ 2
👍👍👍
+ 1
Its working now. Thank you!