JSFiddle - React, Tailwind, and code Playground

HTML

<select id="select1">
    
</select>

<select id="select2">
    
</select>

JavaScript

var options1 = [
    {code: "A", value: 1},
    {code: "B", value: 2} 
];

var options2 = [
    {code: "X", value: 1},
    {code: "Y", value: 2} 
];

function insert_dropdown(options, defaultValue, container) {
    $.each(options, function() {
        container.append("<option value='" + this.code + "'>" + this.value + "</option>");
    });
    
    container.val(defaultValue); //This will select the default option
}

$(function(){
//Assuming options is an array of code/value pair
insert_dropdown(options1, "A", $("#select1"));
insert_dropdown(options2, "Y", $("#select2"));



});