How to get the sunday date of the next week in JavaScript

1 Answer

0 votes
function getSundayOfNextWeek() {
  	const today = new Date();
  	const first = today.getDate() - today.getDay() + 1;
  	const last = first + 6;

  	const sunday = new Date(today.setDate(last));

  	return sunday;
}

console.log(getSundayOfNextWeek().toDateString());

 
  
   
  
/*
run:
  
"Sun Apr 03 2022"
  
*/

 



answered Mar 31, 2022 by avibootz

Related questions

1 answer 187 views
1 answer 138 views
1 answer 120 views
1 answer 152 views
1 answer 141 views
141 views asked Apr 2, 2022 by avibootz
1 answer 144 views
1 answer 138 views
...