title: How to compare two different values of different functions or same function?
body: <p>I have two variables <code>index_1</code> and <code>index_2</code> of different function and I have to compare that. Is that correct method or I can something else  </p>
  
  <p>Currently, I am not satisfied with this code for comparison because every time i get same value:</p>
  
  <pre><code>$(document).ready(function(){
         var index_1 = '';
         var index_2 = '';
  
          $('#spin-now').click(function(){
  
          $(".spin-box-1").jCarouselLite({
              auto: 200,
              speed: 200,
              visible: 1,
              vertical: true,
              easing: "easeOutBounce",
                  afterEnd: function(a) {
                       var index_1 = $(a[0]).index();
                       store_index_1(index_1);    
                  }
          });
  
          $(".spin-box-2").jCarouselLite({
              auto: 225,
              speed: 225,
              visible: 1,
              vertical: true,
              easing: "easeOutBounce",
                  afterEnd: function(a) {
                       var index_2 = $(a[0]).index();
                       store_index_1(index_2);
                  }
          });       
  
      });
  
              function store_index_1(x){
                  data_index_1 = x;
                  data_index_2 = data_index_1 ;
                  if(data_index_2 == data_index_1){
                      //alert('same');
                  }
                 else{
                    alert('different');
                  }
  
  
                    console.log('outside'+''+data_index_1+''+data_index_2);  
              }
  
  //console.log(data_index_1);
  
  
  });
  </code></pre>