Create object with for loop and saving to collection

On my page I have a number of drop downs each call DD1, DD2, etc. In my database I have fields with keys accom1, accom2, etc. I’m trying to create an object using a for loop where the numerical values are replaced with a variable (i):
let updateAccom = {
“accom1”: $w(‘#accomDD1’).value,
“accom2”: $w(‘#accomDD2’).value
}

However, I don’t know the correct syntax for defining the object name as I keep on getting an error when trying this:

“accom”+(i): $w(‘#accomDD’+(i)).value

Can the objects be defined like this?

Joe,

The syntax when you create an object is to have the property name not in quotes:

let updateAccom = {
accom1:$w(’ #accomDD1 ‘).value
,accom2:$w(’ #accomDD2 ').value
}


Thank you, however, I think a better way to explain it is to show this screenshot. Is there a better way to do this with a loop?