title: Uncaught TypeError: Cannot set property 'status' of undefined at HTMLInputElement.updateData JSON Javasscript
body: <p>I have this code which seems to work perfectly fine till I add the last line. To the best of my knowledge the last line too has no mistake but I keep getting the error </p>
  
  <pre><code>firstProjectDifferent_style.html?_ijt=gs7id9qc5jeql1hvnl2cgn56i4:38 Uncaught TypeError: Cannot set property 'status' of undefined
      at HTMLInputElement.updateData 
  </code></pre>
  
  <p>Below is the entire code</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html lang="en"&gt;
  &lt;head&gt;
      &lt;meta charset="UTF-8"&gt;
      &lt;title&gt;JSON Excercise&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;h1&gt;Learn JSON&lt;/h1&gt;
      &lt;div id="output"&gt;
          &lt;ul id="taskList"&gt;
  
          &lt;/ul&gt;
      &lt;/div&gt;
      &lt;script type="text/javascript"&gt;
          var data = '[{"info":"Cut Grass","status":false},{"info":"Clean Room","status":true},' +
              '{"info":"Go to Gyn","status":true},{"info":"Make Dinner Late","status":false}]';
  
          var dataJSON = JSON.parse(data);
          var output = document.getElementById("output");
          var taskList = document.querySelector("#taskList");
          for (var key in dataJSON){
              var status = dataJSON[key].status?"checked":"";
              var html = "&lt;li&gt;"+ dataJSON[key].info + "&lt;input type='checkbox' value='" + dataJSON[key].info + "'" + status +"&gt;&lt;/li&gt;";
              taskList.innerHTML += html
          }
          addEvent();
  
          function addEvent() {
              var checkBoxes = document.querySelectorAll("#taskList li input[type='checkbox']");
              for (var index in checkBoxes){
                  checkBoxes[index].onchange = updateData;
              }
          }
  
          function updateData() {
              var key = event.target.value;
              console.log(key, event.target.checked);
              dataJSON[key].status = event.target.checked; //This line is causing the problem
          }
  
  
  
      &lt;/script&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>