title: Javascript: get Monday and Sunday of the previous week
body: <p>I am using the following script to get Monday (first) and Sunday (last) for the previous week:</p>
  
  <pre><code>var curr = new Date; // get current date
  var first = curr.getDate() - curr.getDay() - 6; // Gets day of the month (e.g. 21) - the day of the week (e.g. wednesday = 3) = Sunday (18th) - 6
  var last = first + 6; // last day is the first day + 6
  var startDate = new Date(curr.setDate(first));
  var endDate = new Date(curr.setDate(last));
  </code></pre>
  
  <p>This works fine if last Monday and Sunday were also in the same month, but I just noticed today that it doesn't work if today is December and last Monday was in November.</p>
  
  <p>I'm a total JS novice, is there another way to get these dates?</p>