title: FreeCodeCamp: Iterating Through All an Array's Items Using For Loops
body: <p>I've got this working block of code from the freecodecamp hint</p>
  
  <pre><code>  function filteredArray(arr, elem) {
    let newArr = [...arr];
  
    for(let i = 0; i &lt; newArr.length; i++) {
      for(let j = 0; j &lt; newArr[i].length; j++) {
        if(newArr[i][j] == elem) {
          newArr.splice(i,1);
          i--;
          break;
        }
      }
    }
  
    return newArr;
  }
  
  console.log(filteredArray([[3, 2, 3], [1, 6, 3], [3, 13, 26], [19, 3, 9]], 3));
  </code></pre>
  
  <p>I understand most part of it but not 
  <code>i--;
  break;</code>
  I really need an explanation as to why <code>i--; break;</code> was used.</p>
  
  <p><a href="https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-data-structures/iterate-through-all-an-arrays-items-using-for-loops/" rel="nofollow noreferrer">https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-data-structures/iterate-through-all-an-arrays-items-using-for-loops/</a></p>