javascript function not executing

please, can anyone help check this code snippets linked below? i have two functions in particular not executing:
1. displayCurTime()
1. displayCurTime()
2. displayMin()
2. displayMin()
https://codepen.io/winniffy/pen/YzOOYdY
winner
CodePen
YzOOYdY
...
3 Replies
13eck
13eck2y ago
In the codepen console:
13eck
13eck2y ago
Line 58 has
getH = setTimeout('displayHour()', refreshH);
getH = setTimeout('displayHour()', refreshH);
But getH is not defined anywhere. In addition, you don't pass a string into a setTimeout function, you pass a function reference. So it should read
getH = setTimeout(displayHour, refreshH);
getH = setTimeout(displayHour, refreshH);
Not a string so no ' and not a function call, but a function to call, so no (). However, I'mm not sure why you'd assign the return value (which is a timeoutID to a variable to never use. If your aim is to set a timeout then you call it like any other function
setTimeout(displayHour, refreshH);
setTimeout(displayHour, refreshH);
winniffy
winniffy2y ago
thanks for the help. i found the error, turns out i wasn't calling the functions in other. so i called the
refresh
refresh
functions before the
display
display
and it worked.
Want results from more Discord servers?
Add your server