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 182 views
1 answer 211 views
1 answer 216 views
1 answer 223 views
1 answer 208 views
1 answer 222 views
1 answer 232 views
...