js循环条件为执行代码后的变量 财富值22

2016-10-26 20:18发布

怎么样改可以让执行代码在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);
4条回答

题主只想在 timeteam[n] <= endtime 的时候执行,也就是 timeteam[n] > endtime 的时候就不执行,于是可以通过 break 跳出题主的那个 while 循环。if (timeteam[n] > endtime) break;

一周热门 更多>