javascript - I need help creating a script to pull the current dates for the week -


i'm not familiar javascript want create script pull every single day of week me. here working right now. enter image description here

i added picture "get date" , make when hit "get date" button, go through script , assign dates cells above monday, tuesday, wednesday, etc. 8/8, 8/9, 8/10.

i think you'll have in 2 steps:

  1. find last monday (which 6 days in past)
  2. starting there, build list of 7 days

var date = new date(),      daysofweek = [];    // find last monday  while(date.getday() != 1) {    date.setdate(date.getdate() - 1);  }    // build array of dates  for(var n = 0; n < 7; n++) {    daysofweek.push((date.getmonth() + 1) + '/' + date.getdate());    date.setdate(date.getdate() + 1);  }    console.log(daysofweek);


Comments