javascript - Interval :30 loop each array -
in javascript how make loop if <=4
returns array of data:
["0:00", "0:30", "1:00", "1:30", "2:00", "2:30", "3:30", "4:00"]
this example interval time ":30".
example:
for (var i=0; i<=4; i++) { a[i] = i.tostring() + ":00"; a[i+1] = i.tostring() + ":30"; }
for (var i=0; i<=4; i++) { a[2 * i] = + ":00"; a[2 * + 1] = + ":30"; }
but solution include 04:30
to around problem can use next code:
for (var i=0; i<=8; i++) { var prefix = % 2 == 0 ? ":00" : ":30"; a[i] = math.floor(i / 2) + prefix; }
Comments
Post a Comment