How to get the friday date of the current week in Node.js

1 Answer

0 votes
function getFridayDateOfCurrentWeek() {
  	const today = new Date();
  	const first = today.getDate() - today.getDay() + 1;
  	const day_of_friday = first + 4;

  	const date_of_friday = new Date(today.setDate(day_of_friday));

  	return date_of_friday;
}

console.log(getFridayDateOfCurrentWeek().toDateString());

  
  
  
  
/*
run:
  
Fri Apr 08 2022
  
*/

 



answered Apr 5, 2022 by avibootz

Related questions

1 answer 107 views
1 answer 126 views
1 answer 125 views
1 answer 127 views
1 answer 117 views
1 answer 126 views
1 answer 158 views
...