title: jQuery - comparing value on each array
body: <p>I'm trying to compare the exact dates inside an array. I added a function that will compare the value into an array using <code>isInArray</code> function. Now I have a list of exact dates inside the array and tried to compare them. My only problem was I'm getting an error says <em>Uncaught TypeError: Cannot read property 'indexOf' of undefined</em> on this code </p>
  
  <pre><code>if (isInArray(get_compare_date, get_all_dates_full)) {  
   ....
  }
  </code></pre>
  
  <p>But when I tried to add a static array it is working good</p>
  
  <pre><code>if (isInArray(get_compare_date, ["November 9, 2017", "November 28, 2017"])) {   
   ....
  }
  </code></pre>
  
  <p>This is what I've tried</p>
  
  <pre><code>    var data_arr = ['2017, 11, 09', '2017, 11, 26', '2017, 11, 29'];
      var get_all_dates_full = new Array;
      $.each(data_arr, function (key, value) {
          get_date_val = new Date(value);
          get_all_dates_full.push(get_date_val.format("mmmm d, yyyy"));
      });
  
      console.log(get_all_dates_full);
  
      function get_all_dates(){
      var now = new Date();
      $(".picker__day").each(function () {
  
          var get_compare_date = $(this).attr('aria-label');  
  
          //problem in if statement...
          if (isInArray(get_compare_date, get_all_dates_full)) {          
          console.log(get_compare_date);
              if (!$(this).hasClass("picker__day--disabled")) {
                  $(this).addClass('picker__day--disabled');
                  $(this).addClass('done-seminar');
              }else{
                  $(this).addClass('not-seminar');
              }
          }
  
      });
      }
  
      });
  
      //compare value into an array
      function isInArray(value, array) {
        return array.indexOf(value) &gt; -1;
      }
  </code></pre>