Not adding duplicate options in dropdown from collection.

Working through pushing data from a collection into a dropdown menu without duplicates while also also making sure the fundraiser is active (today falls between start and end dates).

I’m using array.includes() function to check for duplicates but even if there is a duplicate the dupCheck still comes back false.

Anyone please enlighten me on what I’m not doing correctly to check for duplicates in the opts array when pulling the organization (orgName) name from the query results (results.items[i].lastName)


Running the code for the Order Fundraiser Keychain page. To debug this code in your browser's dev tools, open qwt89.js.

dupCheck came back false
Johnson High School was added to the options  //duplicate item

dupCheck came back false
Union High School was added to the options

dupCheck came back false
South Side High School was added to the options

dupCheck came back false
Johnson High School was added to the options  //duplicate item


import wixData from 'wix-data';

$w.onReady (function () {
    const fundCollection = "paymentForm072";
    var i = 0;
    let opts = $w("#dropdown1").options;
    const today = new Date()
    
wixData.query(fundCollection)
    .find()
    .then((results) => {
        if(results.items.length > 0) 
        {
            i = results.items.length - 1
            //grabs distinct school/organization from collection        
        } 
        else 
        {
            // handle case where no matching items found
        }
        //Populates dropdown1 if fundraisers found
        
        if(results.items.length > 0)
        {
            while (i >= 0) //moves querry result from array, to orgName and pushes into dropdown1 options
            {
                let sDateSet = new Date(results.items[i].dateField)
                let eDateSet = new Date(results.items[i].dateField2)
                //sets check for active dates of fundraisers
                
                let orgName = results.items[i].lastName
                let dupCheck = opts.includes(orgName)
//=====keeps coming back false through there are duplicate entries =====

//sets organization name and checks to see if it's already in the array.

                console.log("dupCheck came back",dupCheck)

                if(sDateSet <= today && eDateSet >= today && dupCheck == false)
                {
                    opts.push({"label":orgName, 'value':orgName})
                    console.log(results.items[i].lastName,"was added to the options")                        
                }
                else
                {
                    //bypasses any action if today doesn't fall within time frame of fundraiser
                }
            
            i--

            }   

        $w('#dropdown1').options = opts //overwrites old options with this set.
        
        }

        else  //
        {
            $w('#dropdown2').options = [{"label": "No Ongoing Fundraisers", "value":"NoFundraisers"}]         
        }
    })

    .catch((err) => {
    console.log(err);

  });
})

Finally found a workaround. Added an array to collect information being passed to dropdown menu options. Used that array to compare to current query result to see if it was a duplicate.