I got 7 variables (seconds), I am using them to show countdown. All of them counting down simultaneously at the same page. I want to set them to '59' after they reached to '0'. I am new to javascript so sorry if it is a silly question.
Here is my code :
s--; s2--; s3--; s4--; s5--; s6--; s7--;
var array_s = [s, s2, s3, s4, s5, s6, s7];
for (var i = 0; i < array_s.length; i++) {
var result = array_s[i];
if( result < 0) {
result = 59;
}
}
Edit: tried this way, too:
var array_s = [s, s2, s3, s4, s5, s6, s7];
for (var i = 0; i < array_s.length; i++) {
if( array_s[i] < 0) {
array_s[i] = 59;
}
}
But they keep counting down after '0'. So, Where is my problem, what am I doing wrong?
Edit: I have edited the mistake in length