Solution 1 :

If i understanded right, you want to excute one function once and excute the other all the time .
So if this was right and let’s say that the first one will be excutable once so the code is gonna be

const formatDayNumber = date =>
date.toLocaleDateString('en-US', { 
 day: 'numeric' });


const incrementDayNumber = date => {
 date.setDate(date.getDate() + 1);
  return date;

  };

 const currentDayChangeNumber = () => {
const now = new Date();

Let dayNum = [...document.querySelectorAll('.day- number')]
for(var i =0 ; i ‹ dayNum.length ; i++){
Let day = dayNum[i]

if (i === 0){

    day.textContent = formatDayNumber(now);

}


    incrementDayNumber(now);

});

}

Problem :

Hello I have this function that populate certain divs with date up to a week… point is every day it update to the current day which is ofc logical how to stop this from happening I just want to grab this date onload once and that’s it.
my speculation, there should be a localstorage element to save it… but how to stop the daily update ?
is it by saving the current grabbed elements to local storage then get them on the next load ?? or is there also some logic needed inside the function itself ?

const formatDayNumber = date =>
    date.toLocaleDateString('en-US', { day: 'numeric' });

    
const incrementDayNumber = date => {
    date.setDate(date.getDate() + 1);
    return date;

};

const currentDayChangeNumber = () => {
    const now = new Date();

    [...document.querySelectorAll('.day-number')].forEach(day => {


        day.textContent = formatDayNumber(now);


        incrementDayNumber(now);

    });

}

By