Setinterval() For An Analogue Clock
I'm quite new to JavaScript and I have trouble working with etInterval(). I'm creating an analogue clock as an exercise. I have a function setTime() that gets and displays the tim
Solution 1:
You are making a function call in setInterval()
.
What you want to do is :
setInterval(setTime,1000);
Solution 2:
when you call you setInterval
function, you don't pass the function reference as a parameter, but it's return value.
So you should use:
setInterval(setTime,1000);
or
setInterval(function(){setTime()},1000);
Solution 3:
The function setTime()
in the line setInterval(setTime(),1000);
is getting evaluated before the setInterval()
function is called, and the results of the evaluation of setTime()
are passed to the setInterval()
function as an argument, rather than the function istelf being passed as an argument.
What you need to do is replace the function call ("setTime()
") with this name of the function ("setTime
") like this:
setInterval(setTime, 1000);
Post a Comment for "Setinterval() For An Analogue Clock"