
Algorithm:
- Create a function that executes every second using
setInterval. - Get the total number of minutes.
- Convert that into seconds and store in a global variable.
- Decrement the seconds by β1β for each second.
- Check if the seconds reaches 0. If true then alert the user and clear the timer.
Coding time! Readyβ Set β Go. Start coding π€©
<script>
var seconds = 0;
var interval ;
function pomodoro(mins) {
seconds = mins*60 || 0;
interval = setInterval(function() {
seconds--;
if(!seconds){
clearInterval(interval);
alert("π¨ It is Cool π. I wish you could share ");
}
},1000)
}
</script>
Thatβs so simple to create an awesomatic π super exclusive pomodoro clock. Follow Javascript JeepπΒ .
If you find this helpful surprise π me here.
Share if you feel happy π π πΒ .