Answer the question
In order to leave comments, you need to log in
Countdown timer with notification. How to do?
Hello!
How can I make it so that after the end of the timer a message is displayed that the time is up?
Here's the timer: https://jsfiddle.net/alexander_js_developer/Lk5v9ncw/
Here's an example message output: https://yournet.info/example/timer/timer-v1.html
Answer the question
In order to leave comments, you need to log in
To display a message, it is better to write a separate function.
For example:
const end = () => {
alert('end');
}
const step = () => {
if( state.timeleft.seconds-1 < 0 ){
if( state.timeleft.minutes !== 0 ){
state.timeleft.seconds = 59;
state.timeleft.minutes = ( state.timeleft.minutes-1 < 0) ? 0 : state.timeleft.minutes-1;
} else {
clearInterval( state.timerId );
end();
}
} else {
state.timeleft.seconds--;
}
render();
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question