title: Cannot read property 'slice' of undefined in jQuery
body: <p>I am using <code>slice()</code> function inside <code>$.each()</code> array. It shows this error when the first half of the array values have the same string. <code>$name</code> is coming from a button which always has a different value i.e <code>question1</code>, <code>question2</code>.</p>
  
  <p>I tried when the array is like <code>var arr = ["question1Answer1", "question2Answer2"];</code> then function works OK but when I push more values starting with <code>question2</code> and want to remove these values than above error shows in the console.</p>
  
  <pre><code>    var arr = ["question1Answer1", "question2Answer2", "question2Answer3"];
      refreshArrange = function($name) {
  
        $.each(arr, function(index, value) {
          var newStr = '';
  
          newStr = value.slice(0, 9);
  
          if(newStr == $name) {
            var ind = arr.indexOf(value);
            if (ind &gt; -1) {
              arr.splice(ind, 1);
              console.log('working Ok');
            }
  
          }else {
  
          }
  
        });
  
        console.log(arr);
      }
  </code></pre>
  
  <p>I want to remove the 2nd and 3rd value of array because the coming value of <code>$name</code> is <code>question2</code>. I am splitting up the array values and compare the first half with <code>$name</code> and removing it. But this error occurs.
  I don't know where the problem is.</p>
  
  <p>Actually, I want to remove the values of the array which starts from the value of <code>$name</code> </p>
  
  <p>I am sorry if this is a stupid question. I know I didn't explain the problem properly.</p>