title: How to populate the default to dropdown in Javascript
body: <p>Good day</p>
  
  <p>My code below populate the lists of warehouses to a dropdown, which is what i want but i also want do make the warehouse with <code>isMainWarehouse = true</code> a default selected when populating the warehouses (note that there is only one main warehouse) </p>
  
  <pre><code>function PopulateWarehouses() {
  
  var warehouseDropDown = document.getElementById('SelectWarehouse');
  var warehouseFragment = document.createDocumentFragment();
  
  _warehouseRepository.getWarehouses().done(function (data) {
      for (var element in data.items) {
          if (data.items.hasOwnProperty(element)) {
  
              var recievedData = data.items[element];
              var id = recievedData.id;
              var name = recievedData.warehouseName;
              var main = recievedData.isMainWarehouse;
              var opt = document.createElement('option');
              opt.innerHTML = name;
              opt.value = id;
              warehouseFragment.appendChild(opt);
          }
      }
      warehouseDropDown.appendChild(warehouseFragment);
      $('#SelectWarehouse').selectpicker('refresh');
  
  });}
  </code></pre>
  
  <p>here is my dropdown</p>
  
  <pre><code> &lt;select id="SelectWarehouse" name="SelectWarehouse" class="selectpicker show-tick  form-control" data-live-search="true"&gt;&lt;/select&gt;
  </code></pre>
  
  <p>This method just get the list of all the warehouses</p>
  
  <pre><code> // GET: get list of all warehouses
      public async Task&lt;ListResultOutput&lt;WarehouseListDto&gt;&gt; GetWarehouses()
     {
          var warehouses = await _warehouseRepository.GetAllListAsync();
  
  
          ListResultOutput&lt;WarehouseListDto&gt; dto = new ListResultOutput&lt;WarehouseListDto&gt;(
                   warehouses
                  .OrderBy(t =&gt; t.WarehouseName)
                  .ToList()
                  .MapTo&lt;List&lt;WarehouseListDto&gt;&gt;()
              );
          return dto;
      }
  </code></pre>