How to get the friday date of the current week in TypeScript

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 117 views
1 answer 115 views
1 answer 188 views
1 answer 148 views
1 answer 154 views
1 answer 156 views
1 answer 144 views
...