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 181 views
1 answer 131 views
1 answer 113 views
1 answer 146 views
1 answer 131 views
131 views asked Apr 2, 2022 by avibootz
1 answer 135 views
1 answer 130 views
...