title: JavaScript error, push is not a function
body: <p>I just started to learn JavaScript. I made a save function to save data to local storage, but everytime I try to save a data, it always get this error: push is not a function. </p>
  
  <p>The error occurs in this piece of code:</p>
  
  <pre><code>var issues = JSON.parse(localStorage.getItem('issues'));
  issues.push(issue);
  </code></pre>
  
  <p>I'm trying to get data from local storage. var issues is supposed to be an array of objects, so then I can push another object into it.</p>
  
  <p>This is the complete code:</p>
  
  <pre><code>function fetchIssues () {
    var issues = JSON.parse(localStorage.getItem('issues'));
    var issuesList = document.getElementById('issuesList');
  
    issuesList.innerHTML = '';
  
    for (var i = 0; i &lt; issues.length; i++) {
      var id = issues[i].id;
      var desc = issues[i].description;
      var severity = issues[i].severity;
      var assignedTo = issues[i].assignedTo;
      var status = issues[i].status;
  
      issuesList.innerHTML +=   '&lt;div class="well"&gt;'+
      '&lt;h6&gt;Issue ID: ' + id + '&lt;/h6&gt;'+
      '&lt;p&gt;&lt;span class="label label-info"&gt;' + status + '&lt;/span&gt;&lt;/p&gt;'+
      '&lt;h3&gt;' + desc + '&lt;/h3&gt;'+
      '&lt;p&gt;&lt;span class="glyphicon glyphicon-time"&gt;&lt;/span&gt; ' + severity + ' '+
      '&lt;span class="glyphicon glyphicon-user"&gt;&lt;/span&gt; ' + assignedTo + '&lt;/p&gt;'+
      '&lt;a href="#" class="btn btn-warning" onclick="setStatusClosed(\''+id+'\')"&gt;Close&lt;/a&gt; '+
      '&lt;a href="#" class="btn btn-danger" onclick="deleteIssue(\''+id+'\')"&gt;Delete&lt;/a&gt;'+
      '&lt;/div&gt;';
    }
  }
  
  document.getElementById('issueInputForm').addEventListener('submit', saveIssue);
  
  function saveIssue(e) {
    var issueId = chance.guid();
    var issueDesc = document.getElementById('issueDescInput').value;
    var issueSeverity = document.getElementById('issueSeverityInput').value;
    var issueAssignedTo = document.getElementById('issueAssignedToInput').value;
    var issueStatus = 'Open';
    var issue = {
      id: issueId,
      description: issueDesc,
      severity: issueSeverity,
      assignedTo: issueAssignedTo,
      status: issueStatus
    }
  
    if (localStorage.getItem('issues') === null) {
      var issues = [];
      issues.push(issue);
      localStorage.setItem('issues', JSON.stringify(issues));
    } else {
      var issues = JSON.parse(localStorage.getItem('issues'));
      issues.push(issue);
      localStorage.setItem('issues', JSON.stringify(issues));
    }
  
    document.getElementById('issueInputForm').reset();
  
    fetchIssues();
  
    e.preventDefault(); 
  }
  
  function setStatusClosed (id) {
    var issues = JSON.parse(localStorage.getItem('issues'));
  
    for(var i = 0; i &lt; issues.length; i++) {
      if (issues[i].id == id) {
        issues[i].status = "Closed";
      }
    }
  
    localStorage.setItem('issues', JSON.stringify(issues));
  
    fetchIssues();
  }
  
  function deleteIssue (id) {
    var issues = JSON.parse(localStorage.getItem('issues'));
  
    for(var i = 0; i &lt; issues.length; i++) {
      if (issues[i].id == id) {
        issues.splice(i, 1);
      }
    }
  
    localStorage.setItem('issues', JSON.stringify(issues));
  
    fetchIssues();
  }
  </code></pre>