[removed] Restart loop once at the end of an array

前端 未结 5 985
孤独总比滥情好
孤独总比滥情好 2021-01-23 21:31

I recently came across this problem and can\'t find a good answer anywhere (hence the question).

I want to restart the loop once i reach the end yet only loop a finite a

5条回答
  •  后悔当初
    2021-01-23 22:14

    If you want [tomorrow, tomorrow + 1, ..., tomorrow + 6]:

    for (let i = 1; i <= 7; i++) {
      week.push(dayNames[(dayNum + i) % 7]);
    }
    

提交回复
热议问题