title: adding .json data to table using vanilla javascript
body: <p>I want to add json data to the table in HTML using vanilla javascript (no jquery) how can I do that ? below you will find the html code and the json data :</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>function myFunction() {
    // Declare variables
    var input, filter, table, tr, td, i;
    input = document.getElementById("myInput");
    filter = input.value.toUpperCase();
    table = document.getElementById("myTable");
    tr = table.getElementsByTagName("tr");
  
    // Loop through all table rows, and hide those who don't match the search query
    for (i = 0; i &lt; tr.length; i++) {
      td = tr[i].getElementsByTagName("td")[0];
      if (td) {
        if (td.innerHTML.toUpperCase().indexOf(filter) &gt; -1) {
          tr[i].style.display = "";
        } else {
          tr[i].style.display = "none";
        }
      }
    }
  }</code></pre>
  <pre class="snippet-code-css lang-css prettyprint-override"><code>#myInput {
    background-image: url("/css/searchicon.png"); /* Add a search icon to input */
    background-position: 10px 12px; /* Position the search icon */
    background-repeat: no-repeat; /* Do not repeat the icon image */
    width: 100%; /* Full-width */
    font-size: 16px; /* Increase font-size */
    padding: 12px 20px 12px 40px; /* Add some padding */
    border: 1px solid #ddd; /* Add a grey border */
    margin-bottom: 12px; /* Add some space below the input */
  }
  
  #myTable {
    border-collapse: collapse; /* Collapse borders */
    width: 100%; /* Full-width */
    border: 1px solid #ddd; /* Add a grey border */
    font-size: 18px; /* Increase font-size */
  }
  
  #myTable th,
  #myTable td {
    text-align: left; /* Left-align text */
    padding: 12px; /* Add padding */
  }
  
  #myTable tr {
    /* Add a bottom border to all table rows */
    border-bottom: 1px solid #ddd;
  }
  
  #myTable tr.header,
  #myTable tr:hover {
    /* Add a grey background color to the table header and on hover */
    background-color: #f1f1f1;
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;!doctype html&gt;
  &lt;html&gt;
  
  &lt;head&gt;
      &lt;meta charset="utf-8"&gt;
      &lt;title&gt;Table&lt;/title&gt;
      &lt;link rel="stylesheet" href="./assets/css/style.css"&gt;
      
  &lt;/head&gt;
  
  &lt;body&gt;
      &lt;input type="text" id="myInput" onkeyup="myFunction()" placeholder="Search for names.."&gt;
  
      &lt;table id="myTable"&gt;
          &lt;tr class="header"&gt;
              &lt;th style="width:10%;"&gt;Picture&lt;/th&gt;
              &lt;th style="width:15%;"&gt;Name&lt;/th&gt;
              &lt;th style="width:5%;"&gt;Age&lt;/th&gt;
              &lt;th style="width:5%;"&gt;Active&lt;/th&gt;
              &lt;th style="width:20%;"&gt;Email&lt;/th&gt;
              &lt;th style="width:20%;"&gt;Phone&lt;/th&gt;
              &lt;th style="width:10%;"&gt;Company&lt;/th&gt;
              &lt;th style="width:10%;"&gt;Balance&lt;/th&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;img src="http://placehold.it/32x32" alt=""&gt;&lt;/td&gt;
              &lt;td&gt;Joseph Keller&lt;/td&gt;
              &lt;td&gt;24&lt;/td&gt;
              &lt;td&gt;true&lt;/td&gt;
              &lt;td&gt;josephkeller@twiist.com&lt;/td&gt;
              &lt;td&gt;+1 (827) 592-2357&lt;/td&gt;
              &lt;td&gt;TWIIST&lt;/td&gt;
              &lt;td&gt;$3,507.97&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/table&gt;
  &lt;/body&gt;
  &lt;script src="./assets/js/main.js"&gt;&lt;/script&gt;
  
  &lt;/html&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>and here is part of json data that I want to appear in table :</p>
  
  <pre><code>    [
    {
      "_id": "5af5cf0270d455a211200d4c",
      "isActive": true,
      "balance": "$3,507.97",
      "picture": "http://placehold.it/32x32",
      "age": 24,
      "eyeColor": "brown",
      "name": "Joseph Keller",
      "gender": "male",
      "company": "TWIIST",
      "email": "josephkeller@twiist.com",
      "phone": "+1 (827) 592-2357",
      "address": "661 Terrace Place, Elliott, Ohio, 9927",
      "about": "Id sint labore sint dolore ex laboris. Ea irure dolor est nulla laboris Lorem sint fugiat laborum officia commodo. Reprehenderit culpa non voluptate ea. Fugiat duis et deserunt ea enim et ipsum nostrud commodo quis quis laborum officia. Elit est anim quis deserunt nulla nostrud ea eiusmod quis adipisicing. Mollit exercitation officia ipsum ea aliqua amet aliqua esse amet minim. Ipsum quis cillum fugiat reprehenderit sit aliquip aute in excepteur dolore fugiat esse non non.\r\n",
      "registered": "2014-12-10T07:18:10 +02:00",
      "latitude": -84.359436,
      "longitude": 156.008804,
      "tags": [
        "excepteur",
        "eiusmod",
        "laboris",
        "fugiat",
        "minim",
        "dolor",
        "qui"
      ],
      "friends": [
        {
          "id": 0,
          "name": "Shields Terrell"
        },
        {
          "id": 1,
          "name": "Hilary Bruce"
        },
        {
          "id": 2,
          "name": "Lorraine Torres"
        }
      ]
    }
  </code></pre>
  
  <p>can someone help ? I want to know how to do it using vanilla javascript</p>
  
  <p>thank you</p>