Compress CODE

This part here…

async function uniqueTitles_DropDowns (parameter) {
 let loadedDatabase = wixData.query(DATABASE)
 let Options = []

 for (var a = 0; a < refFields.length; a++) {
 let myCHBarray = [refFields[0], refFields[1], refFields[2], refFields[3], refFields[4]]
 await loadedDatabase.distinct(myCHBarray[a])
        .then(async(results) => {
 if (results.items.length > 0) {
 let items = results.items;
 
 for (var b = 0; b <items.length; b++) {//console.log(items[b])      
                    Options.push([])    
                    Options[a].push({"label": items[b], "value": items[b]})
                }   
                console.log(Options[a]) 
                $w('#DD'+(a+1)).options = await Options[a]
            }
        })
    }
}

Gets all the unique values of each Dropdowns.
I want the code to be able to recognize AUTOMATIC, how much VALUES are active in the USER-INTERFACE…

USER-INTERFACE—>

var REFERENCE1  = "value1"        ;   
var REFERENCE2  = "value2"        ;   
var REFERENCE3  = "value3"        ;    
var REFERENCE4  = "value4"        ;   
var REFERENCE5  = "value5"        ;   
var REFERENCE6  = ""              ;  
var REFERENCE7  = ""              ;  
var REFERENCE8  = ""              ;    
var REFERENCE9  = ""              ;   
var REFERENCE10 = ""              ;   

Recognizing the length of —> refFields —> like in this example —> ( 5-active-values )
with a loop…

for (var a = 0; a < refFields.length; a++) {

}

This codeline is my problem…

let myCHBarray = [refFields[0], refFields[1], refFields[2], refFields[3], refFields[4]

How to convert (to transform it) into …

let myCHBarray = [refFields[a]] 

… so that the active refFields are found automatic and just all the active DropDowns are filled with unique titles.