title: cannot read property '0' of undefined in ARRAY Javascript
body: <p>ok, this is really making me nuts. i cant figure out why i keep getting <code>uncaught typeError: cannot read property '0' of undefined</code></p>
  
  <p>can someone please point whats causing the <code>uncaught error</code> on this ARRAY line <code>num = myArray[0];</code> </p>
  
  <pre><code> var val= this.value;
  
   myArray = checkinput(val); 
   num = myArray[0];
   data = myArray[1];
  
   if (num == 0 ) { 
    ....
   } else {
    ....
   }
  
  /*FUNCTIONS*/
  
  function checkinput(val) {
  var val;
  //some regex here
  
  if (regexA.test(val)) {
      var fname = val.match(regexA)[0];
      var arr = [0,fname]; // 0 as identifier
      return arr;
      }   
  
  else if (regexB.test(val)) {
      var lname = val.match(regexB)[0];
      var arr= [1,lname]; // 1 as identifier
      return arr;
      }
  }
  </code></pre>