title: Data pushed to array does not remain in the array
body: <p>having a strange issue with JS/jQuery. When I push data from a while loop into an array, the data becomes local to the loop.</p>
  
  <p>ignoring the fact my code barely works, if I move console.log(bxStore); into my document ready {} or anywhere below the while loop, it reads undefined.</p>
  
  <pre><code>var bxRegEx =  new RegExp(/[b][x]\d*[y]\d*[w]\d*[h]\d*/) //identifier 
  
  expression
  
  function bxCycle(){ //cycle html for indbx identifiers
      var cycle = 0
      var bxIdGet = document.getElementsByTagName('div')[cycle].outerHTML
  
      var bxStore = new Array()
      while (bxRegEx.test(bxIdGet)){
          bxStore.push(bxRegEx.exec(bxIdGet))
          cycle++
          bxIdGet = document.getElementsByTagName('div')[cycle].outerHTML
      console.log(bxStore)
      }
  }
  
  $(document).ready(function(){
      bxCycle()
  
  })
  </code></pre>
  
  <p><a href="https://codepen.io/anon/pen/wrRVKw?editors=1112" rel="nofollow noreferrer">https://codepen.io/anon/pen/wrRVKw?editors=1112</a></p>
  
  <p>edit: doesn't appear to be a variable scope issue guys, my example does show it within the function, but when declaring it outside I get the same issue.</p>