I'm working on Timer of hrs seconds minutes. I use setInterval for start it. but when click on button to restart the timer it doesn't work again. The button suppose to clear the timer ( clearInterval ), then restart it again.
I Tried calling the function which contains the timer after clearInterval but timer still doesn't work.
Timer Code
function gameTimer(intervalTime){
var input = {
hours: 0,
minutes: 0,
seconds: 0
};
var timestamp = new Date(input.hours, input.minutes, input.seconds);
var interval = intervalTime;
setInterval(function () {
timestamp = new Date(timestamp.getTime() + interval * 1000);
document.querySelector('.countdown2').innerHTML = timestamp.getHours() + 'h:'
+ timestamp.getMinutes() + 'm:' + timestamp.getSeconds() + 's';
}, Math.abs(interval) * 1000);
}
gameTimer(1);
reset function
function resetFunc(){
clearInterval(gameTimer(0))
}
let reset = document.getElementById('restart');
reset.addEventListener('click', resetFunc);
after this function i call the timer function again to restart the timer again but it's not working
gameTimer(1);
clearIntervalworks - Andreas