function formatDate(date, daysToSubtract) {
  const year = date.getFullYear();
  const month = String(date.getMonth() + 1).padStart(2, "0");
  const day = String(date.getDate() - daysToSubtract).padStart(2, "0");
  return `${day}.${month}.${year}`;
}
const todayCurrentPrices = new Date();
let daysToSubtract = 0;
if (todayCurrentPrices.getDay() === 6) {
  daysToSubtract = 1;
} else if (todayCurrentPrices.getDay() === 0) {
  daysToSubtract = 2;
}
const dateOptionTodayCurrentPrices = formatDate(todayCurrentPrices, daysToSubtract);
daha temiz ve okunabilir hale getirdim, arasındaki farkı görebilirsin. formatDate bir fonksiyon ve bunu 3 sefer kullanmışsın. en üstte kalabilir.