怎么样改可以让执行代码在timeteam[n] <= endtime 的条件下执行循环?
//时间 var startdate = new Date("2016-10-24 20:00:00"); var starttime = startdate.getTime(); var enddate = new Date("2016-10-26 20:00:00"); var endtime = enddate.getTime(); var timeteam = new Array(); var s = 0; var sri = ""; var m; var n = 0 do{ timeteam[n] = starttime + 1800000*s; s++; var myDate = new Date(timeteam[n]); var m = myDate.getFullYear() + "/" + myDate.getMonth() + "/" + myDate.getDate() + " " + myDate.getHours() + ":" + myDate.getMinutes() + ","; sri = sri + m; n++; } while(n < 20) var ss = sri.split(","); ss.pop(); console.log(ss);
付费偷看金额在0.1-10元之间
蟹妖
}while(true);
题主只想在
timeteam[n] <= endtime
的时候执行,也就是timeteam[n] > endtime
的时候就不执行,于是可以通过break
跳出题主的那个while
循环。if (timeteam[n] > endtime) break;
do{
一周热门 更多>