0

What is error in my coding.

Anyone find the error in my coding. Error shows in console but I cannot find out it. https://code.sololearn.com/Wj1xu089x69z/?ref=app

6th Jan 2018, 10:44 AM
Satish Kumar Sharma
Satish Kumar Sharma - avatar
5 odpowiedzi
+ 14
Remove line 70 and change line 1 from "window.onload = num()" to "window.onload = num"
6th Jan 2018, 11:16 AM
Valen.H. ~
Valen.H. ~ - avatar
+ 4
Reading the error message in the console should give you the answer: your 'p' variable isn't defined... in fact, in some circunstances/context/browsers it could have been silently and implicitly as the html reference of element with id 'p', but it's safer to explicitly define it. var p = document.getElementBy('p'); Obviously, you need to define it in the onload body function, but also either define it in global scope or in the local scope of the setInterval callback function (wich will loose its parent local scope at runtime, and will act as the function was defined in the global scope)... So, shorter fix would be to replace: p.innerHTML = "#" + hexa ; By: document.getElementById('p').p.innerHTML = "#" + hexa ;
6th Jan 2018, 11:13 AM
visph
visph - avatar
+ 1
in the html file you should not give the divs a duplicted class name and in the css file the problem is the "//" because css does not support a one line comment.
6th Jan 2018, 11:02 AM
Luca
0
I'm guessing it runs for a huge time before dying as it didn't for me before I gave up. Once ffffff is hit, n should be reset to zero or interval should be canceled. Eventually, you will overflow the maximum number and generate an error.
6th Jan 2018, 11:16 AM
John Wells
John Wells - avatar
- 1
Turns out you are making use of a browser byproduct. Line 72, 73, and 74 shouldn't work, but does because the browser happens to allocate id's as global variables. You should make the same change to those lines you made to 70. Your code will break with Internet Explorer as it doesn't do it that way. See second post 1/3 of the way down last bold text paragraph. https://stackoverflow.com/questions/6852883/can-i-use-an-id-as-a-variable-name
6th Jan 2018, 3:12 PM
John Wells
John Wells - avatar