Advice on efficient code for dropdown population

Hi folks, Thanks to everyone that is so very helpful on this forum, it has helped my journey to be a little more competent with the coding on my site.
I have been trying to expand my Wix code knowledge and increase the efficiency on the site, one area that seems to have lots of code across many pages (the same dropdowns use this code) I have around 3 for this particular input. I was wondering if it would be possible if anyone could change my thinking? Could I code it backend to reduce the code on the pages?

Thank you!

wixData.query('dropdownPopulation')
            .ascending("courseName")
            .find()
            .then(res => {
 let options = [{
 "value": '',
 'label': 'All Courses'
                }];
                options.push(...res.items.map(title => {
 return {
 'value': title.title,
 'label': title.title
                    };
                }));
                $w('#coursenamedropdown').options = options;
            });

 let opts = $w("#durationdropdown").options;
        opts.unshift({
 'value': '',
 'label': 'All Durations'
        });
        $w("#durationdropdown").options = opts;

 let opts2 = $w("#dropdownDifficulty").options;
        opts2.unshift({
 'value': '',
 'label': 'All Grades'
        });
        $w("#dropdownDifficulty").options = opts2;

 let opts3 = $w("#regionDropdown").options;
        opts3.unshift({
 'value': '',
 'label': 'All Regions'
        });
        $w("#regionDropdown").options = opts3;
 let opts4 = $w("#CourseAccomodationDropdown").options;
        opts4.unshift({
 'value': '',
 'label': 'Anywhere will do'
        });
        $w("#CourseAccomodationDropdown").options = opts4;

    }