Why does not the clock code work when I run it on my computer's browser ? | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
+ 1

Why does not the clock code work when I run it on my computer's browser ?

function printTime() { var d = new Date(); var hours = d.getHours(); var mins = d.getMinutes(); var secs = d.getSeconds(); document.body.innerHTML = hours+":"+mins+":"+secs; } setInterval(printTime, 1000);

16th Mar 2018, 4:12 PM
Mouhamadou Lamine Ly
Mouhamadou Lamine Ly - avatar
6 Respostas
+ 3
Again, it works without problems. Is the script importing well? (check how I import it here). Similarly, see if your browser has support for scripts enabled. PS: Add a bit of CSS to the Body element. The code works in firefox (developer edition), but the default color of the font is white. <!DOCTYPE html> <html> <head> <title>Page Title</title> </head> <body> <script src="time.js"> </script> </body> </html>
16th Mar 2018, 4:53 PM
Mickel
Mickel - avatar
+ 8
Your code runs well as I tested it on Opera Mini browser, even with its reputation for having below average of good JavaScript implementation as a browser, just wanted to let you know...
16th Mar 2018, 5:02 PM
Ipang
+ 2
The code works fine in my browser. How are you runing it?
16th Mar 2018, 4:21 PM
Mickel
Mickel - avatar
+ 2
Can you create your code in Code Playground and later attach it here?
16th Mar 2018, 4:32 PM
Mickel
Mickel - avatar
+ 2
yes
16th Mar 2018, 4:39 PM
Mouhamadou Lamine Ly
Mouhamadou Lamine Ly - avatar
+ 1
I write this code in <script> Tag
16th Mar 2018, 4:28 PM
Mouhamadou Lamine Ly
Mouhamadou Lamine Ly - avatar