title: Check pattern with Javascript
body: <p>I'm trying to generate a check pattern with 16x16 squares
  in JavaScript.</p>
  
  <p>I managed to generate a SVG with 16x16 squares but unfortunately they got all the same color.</p>
  
  <p>Here is an example:</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>sx = 16;
  sy = 16;
  qx = 180 / sx;
  qy = 180 / sy;
  m = 0;
  qs = [];
  for(n = 0;n&lt;sy;n++)
  for (m = 0; m &lt; sx; m++) {
    qk = [];
    qa = [];
    qa.push(m * qx);
    qa.push(n * qy);
    qk.push(qa);
    qb = [];
    qb.push(m * qx + qx);
    qb.push(n * qy);
    qk.push(qb);
    qc = [];
    qc.push(m * qx + qx);
    qc.push(n * qy + qy);
    qk.push(qc);
    qd = [];
    qd.push(m * qx);
    qd.push(n * qy + qy);
    qk.push(qd);
    qs.push(qk);
  }
  for (i = 0; i &lt; qs.length; i++) {
    x = [];
    for (j = 0; j &lt; qs[i].length; j++) {
      if (j == 0) {
        x.push("M" + qs[i][j][0] + " " + qs[i][j][1]);
      } else {
        x.push("L" + qs[i][j][0] + " " + qs[i][j][1]);
      };
    };
    p = document.createElementNS('http://www.w3.org/2000/svg', "path");
    p.setAttribute("fill", "red");
    p.setAttribute("d", x.join(""));
    bild.appendChild(p);
  };</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;svg id="bild" viewBox="0 0 180 180" width="500" height="500"&gt;
  &lt;rect width="180" height="180" fill="white"/&gt;
  &lt;/svg&gt;</code></pre>
  </div>
  </div>
  </p>