Pomodoro clock - countdown not working

Pomodoro clock - countdown not working
0.0 0

#1

Hi,
I´m trying to do the pomodoro clock, but the countdown is not working in my code. :frowning: So I want to do a simple timer first, but the countdown is still not working. :disappointed_relieved: Am I completely wrong with my code, or where is the bug?
My project Link - https://codepen.io/mmajam/pen/Jvdrgv?editors=0011
Many thanks for your advice. :wink:


#2

I don’t quite get your code but you are missing a */ at the end of your commented clear interval. That is why your console is not working.

I don’t really know if the way you set up the variables would work (I’m not really good at this myself) but you should start by using the console.log with every small step to see where it is not working and what the variables are actually holding on each step.


#3

I was wondering, why my console shows nothing! :thinking: So thanks for finding the reason - I´m going to check it now with the console working. :wink:


#4

Hy friend i can help you but i m bad in english


#5

You didn’t convert your min variable to seconds and then in set intervel you must convert this min to minute and seconds and output it and decrement the first min variable


#6

Something wrong you work with jquery you must put your code inside
$(document).ready(function(){
your code here
})


#7

Try with this
Var min=25; // on minute
Var minSec=min×60;
var sec;var time;
// function to convert time
function convertTime(){
If(minSec > 60){
min=Math.floor(minSec/60);
sec=minSec%60;
min=(min >10)? min: “0”+min;
sec=(sec > 10)? sec:“0”+sec;
}
time=min+":"+sec;
return time;
}
setInterval(function(){
time=convertTime();
$(“where to output your time”).html(time);
minSec -=1;
},1000);