I think this is a duplicate but I can't find one right now. Your problem is the way you go about adjusting the dates. Date methods modify the Date they're called on, so you are modifying curr as you go but treating it as if it hasn't changed.
// current date
curr = new Date(new Date().getTime() + 60 * 60 * 24 * 7);
That's not a good way to add 1 day, but not your issue. Much better to first zero the time then add one to the date.
console.log(curr);
// Fri Sep 01 2017 01:52:15
// First day of week
var first = curr.getDate() - curr.getDay();
Sets first to -4 (date is 1, Friday is 5).
// Last day week
var last = first + 6;
Sets last to 2 (-4 + 6).
var startDate = new Date(curr.setDate(first));
This modifies curr to be 27 August. It is then copied to create a new Date that is assigned to startDate (i.e. curr and startDate have the same time value and represent the same date and time).
console.log(startDate);
// Sun Aug 27 2017 01:57:25
Yep. Now you set the date for curr to 2, i.e. 2 August.
var endDate = new Date(curr.setDate(last));
console.log(endDate);
// Wed Aug 02 2017 01:59:37
Yep. As an alternative, copy the original date and modify the copy to get startDate, then get another copy and modify it for the end date.
function getWeekStartEnd(date) {
// Copy date so don't modify original
date = date? new Date(+date) : new Date();
// Set time to 0 and copy date at same time
var startDate = new Date(date.setHours(0,0,0,0));
// Set startDate to previous Sunday
startDate.setDate(startDate.getDate() - startDate.getDay());
// Set endDate to next Saturday
var endDate = new Date(+date);
endDate.setDate(endDate.getDate() + 6 - endDate.getDay());
return [startDate, endDate];
}
// Current week
getWeekStartEnd().forEach(function(d){
console.log(d.toString());
});
// For Friday 1 September, 2017
getWeekStartEnd(new Date(2017,8,1)).forEach(function(d){
console.log(d.toString());
});
// For Sunday 3 September, 2017
getWeekStartEnd(new Date(2017,8,3)).forEach(function(d){
console.log(d.toString());
});