Creating new array for repeater

Hi folks,

Looking for a little help with building a new array to populate a repeater. I have a database and this has 12 dates (only 6 shown to keep the code shorter) which populate a repeater. This all works fine. What I’m trying to achieve is that if the date has passed then the code will build a new objected array to populate the repeater again.

The work around I have at the moment is to collapse the repeater container but it’s messy for the user as it populates the repeater before collapsing passed dates.

I’ve had a play around with this for a while but kept the code simple to show what I trying to achieve.

Any help would be greatly appreciated.
Thanks, Stephen

let allDates = [{
            date: item.dateOne,
        }, { date: item.dateTwo, }, { date: item.dateThree, }, { date: item.dateFour, }, { date: item.dateFive, }, { date: item.dateSix, }];
    
    allDates.forEach((el, i) => {

        let today = new Date();
        allDates[i]._id = gettRandomID()
        if (el.date > today) {
            console.log(el.date) //correct dates show on the console log
        }
    })

    $w('#datesRptr').data = allDates;

What is the code of function gettRandomID () ?

Hey, I managed to get it sorted. Had a bit of a brain stall and turns out I was making it too complicated!

The random ID is to set the ID of each item in the array.

let arr = [];
    allDates.forEach((el, i) => {

        let today = new Date();
        allDates[i]._id = gettRandomID()
        if(el.date > today)arr.push(el)

    })
console.log(arr)

function gettRandomID() { return Math.random().toString(36).substring(7) }