title: TyperError: Cannot read property "length" of undefined --- but it is defined?
body: <p>Uncaught TypeError: Cannot read property 'length' of undefined
      at buildTable (test.js:14)
      at test.js:2</p>
  
  <p>I'm not entirely sure what is happening here. I am getting this error, it seems like its saying my array is undefined, but it is defined?</p>
  
  <p>edit: its referring to the code in the loop.</p>
  
  <pre><code>var table = document.getElementById("tableBody");
  buildTable();
  
  var toDoArray = [];
  
  
  function buildTable(){
  
  var retrievedTaskObject = localStorage.getItem("task");
  var parsedObject = JSON.parse(retrievedTaskObject);
  var addTheTaskName = parsedObject.taskName;
  var addTheTaskDate = parsedObject.taskDate;
  
  for(i=0; i &lt; toDoArray.length; i++){
    addTaskToTable(parsedObject[i]);
  }
  
  
  
  }
  
  function addTaskToTable(obj){
    var row = table.insertRow(0);
    var cellName = row.insertCell(0);
    var cellDate = row.insertCell(1);
    var cellId = row.insertCell(2);
    var cellCheck = row.insertCell(3);
    cellName.innerHTML= obj.name;
    cellDate.innerHTML= obj.date;
    var checkStuff = "&lt;input type='checkbox'&gt;";
    cellCheck.innerHTML = checkStuff;
  
  }
  
  function submitForm(name,date) {
      var addTaskName = document.getElementById("taskName").value;
      var addTaskDate = document.getElementById("dateTask").value;
      var taskSomething = getTaskObj(addTaskName,addTaskDate);
        toDoArray.push(taskSomething);
        addTaskToTable(taskSomething);
        var storedArray = JSON.stringify(toDoArray);
        localStorage.setItem("task",storedArray);
  };
  
  function getTaskObj(taskName,taskData){
  var taskObject = {
          name: taskName,
          date: taskData,
        };
   return taskObject;
  }
  </code></pre>