title: How to fill a canvas with a select color?
body: <p>I'm trying to fill a rectangle canvas with some colors from a dropbox.
  Right now, I'm trying to fill the canvas with: white, red, blue, green. When click in the button Add color show fill the canvas with the selected color. When click Clear Button, should reset/remove the color.</p>
  
  <p>So far my html code is:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
    &lt;head&gt;
      &lt;meta charset="utf-8"&gt;
      &lt;title&gt;&lt;/title&gt;
      &lt;script src="colors.js" type="text/javascript" defer&gt;&lt;/script&gt;
    &lt;/head&gt;
  
    &lt;body onload="setUp()"&gt;
      &lt;h1&gt;Canvas colors&lt;/h1&gt;
  
       &lt;p&gt;What colors should fill?
         &lt;select&gt;
          &lt;option value="white"&gt;White&lt;/option&gt;
          &lt;option value="red"&gt;Red&lt;/option&gt;
          &lt;option value="blue"&gt;Blue&lt;/option&gt;
          &lt;option value="green"&gt;Green&lt;/option&gt;
         &lt;/select&gt;
       &lt;button type="button" id="addColor" name="button"&gt;Add Color&lt;/button&gt;
       &lt;button type="button" id="clearColor" name="button"&gt;Clear Color&lt;/button&gt;
      &lt;/p&gt;
  
      &lt;br&gt;
      &lt;br&gt;
  
      &lt;canvas id="myCanvas" height="300" width="300" style="border: 1px solid black"&gt;&lt;/canvas&gt;
  
    &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>JS:</p>
  
  <pre><code>let canvas;
  let ctx;
  
  function setUp(){
     canvas = document.getElementById("myCanvas");
     ctx = canvas.getContext("2d");
     let addColor = document.getElementById('addColor');
     let clearColor = document.getElementById('clearColor');
     myCanvas();
  
  }
  
  addColor.onclick = function() {
    function myCanvas(){
    ctx.fillStyle = ["white", "red", "blue", "green", "pink", "purple", "black", "orange"];
    ctx.fillRect(0, 0, canvas.width, canvas.height);
   }
  }
  
  clearColor.onclick = function() {
    function myCanvas(){
      ctx.fillStyle = white;
      ctx.fillRect(0, 0, canvas.width, canvas.height);
     }
  }
  </code></pre>