title: Creating an if in a js function
body: <p>This is a code that filter all order history the user have but a want to create an if to just filter only the orders that I bought online (I have a variable that is 1 if is in the store and 2 if is online). How to i do the if? </p>
  
  <pre><code>filterOrderHistory: function() {
              $(".historyorder-state").on('click', function(){
                  $('#filterOptions').show();
              });
              $('#filterOptions li').on('click', function() {
                  var text = $(this).text();
                  $('.tbl-shopping-history').html('&lt;div class="form-spinner"&gt;&lt;i class="fa fa-spinner fa-spin"&gt;&lt;/i&gt;&lt;/div&gt;');
                  $.ajax({
                      method: "GET",
                      data: { state: $(this).attr('class').toUpperCase() },
                      dataType: "html",
                      url: '/impuls/store/components/order-history-table.jspf'
                  })
                  .done(function(data) {
                      $('.tbl-shopping-history').html(data);
                      $('.historyorder-state').html(text+'&lt;i class="fa fa-caret-down"&gt;&lt;/i&gt;');
                      $('#filterOptions').hide();
                  });
              });
          }
      };
  </code></pre>