please check my code, I've created a simple date in JS but it's not working, I'm following a tutorial and I have the exact code.
<html> <head> <title>Clock</title> <script> function time() { var time = new Date(); var hours = time.getHours(); var mins = time.getMinutes(); var secs = time.getSeconds(); if (secs<10) { secs = "0" + secs; } if (mins<10) { secs = "0" + mins; } document.getElementById("thetime").innerHTML=hours+":"+mins+":"+secs; var timer = setTimeout(function(){time()},500); } </script> </head> <body onload="time()"> <div id="thetime"></div> </body> </html>
setTimeout(time, 500)Uncaught TypeError: object is not a functionis thrown.