Javascript end of week

javascript
function endOfWeek(date) {
    const lastday = date.getDate() - (date.getDay() - 1) + 6;
    return new Date(date.setDate(lastday));
}

const dt = new Date(); 
console.log(endOfWeek(dt).toString());