title: Udacity Pixel art maker
body: <p>I am asked to make a pixel art maker that makes a table and let's the user color the cells by clicking on them.
  I made it, and it passed 4 tests but in the last one it tells me&quot;
  Pixel Art Project works correctly with randomly sized tables
  Timed out retrying: Too many elements found. Found '3', expected '2'.&quot;
  even though it works correctly when I put random height and width.
  <br>here's my code:</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>var sumb = document.querySelector('#sizePicker [type="submit"]');
  document;
  
  var table = document.querySelector("#pixelCanvas");
  var colpik = document.querySelector("#colorPicker");
  
  function makeGrid() {
   
    var hieght = document.querySelector("#inputHeight").value;
    var width = document.querySelector("#inputWidth").value;
  
    for (var row = 0; row &lt; hieght; row++) {
      tr = document.createElement("tr");
      for (var cell = 0; cell &lt; width; cell++) {
        td = document.createElement("td");
        tr.insertAdjacentElement("afterbegin",td)
      }
      table.insertAdjacentElement("afterbegin",tr)
    }
  }
  
  sumb.addEventListener("click", function (event) {
    event.preventDefault();
  });
  sumb.addEventListener("click", makeGrid);
  
  table.addEventListener("click", function (event) {
    if (event.target.tagName === "TD") {
      var colval = document.querySelector("#colorPicker").value;
      event.target.style.backgroundColor = colval;
    }
  });</code></pre>
  <pre class="snippet-code-css lang-css prettyprint-override"><code>body {
    text-align: center;
  }
  
  h1 {
    font-family: Monoton;
    font-size: 70px;
    margin: 0.2em;
  }
  
  h2 {
    margin: 1em 0 0.25em;
  }
  
  h2:first-of-type {
    margin-top: 0.5em;
  }
  
  table,
  tr,
  td {
    border: 1px solid black;
  }
  
  table {
    border-collapse: collapse;
    margin: 0 auto;
  }
  
  tr {
    height: 20px;
  }
  
  td {
    width: 20px;
  }
  
  input[type="number"] {
    width: 6em;
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  
  &lt;head&gt;
      &lt;title&gt;Pixel Art Maker!&lt;/title&gt;
      &lt;link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Monoton"&gt;
      &lt;link rel="stylesheet" href="styles.css"&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
      &lt;h1&gt;Lab: Pixel Art Maker&lt;/h1&gt;
  
      &lt;h2&gt;Choose Grid Size&lt;/h2&gt;
      &lt;form id="sizePicker"&gt;
          Grid Height:
          &lt;input type="number" id="inputHeight" name="height" min="1" value="1"&gt; Grid Width:
          &lt;input type="number" id="inputWidth" name="width" min="1" value="1"&gt;
          &lt;input type="submit"&gt;
      &lt;/form&gt;
  
      &lt;h2&gt;Pick A Color&lt;/h2&gt;
      &lt;input type="color" id="colorPicker"&gt;
  
      &lt;h2&gt;Design Canvas&lt;/h2&gt;
      &lt;table id="pixelCanvas"&gt;&lt;/table&gt;
  
      &lt;script src="designs.js"&gt;&lt;/script&gt;
  &lt;/body&gt;
  
  &lt;/html&gt;</code></pre>
  </div>
  </div>
  </p>