title: Using the random() function in p5.js
body: <p>I am trying to create a code where a smiley face is drawn at random on-screen and in a random colour which should loop but I can't figure out how best to use the random() function to accomplish this. Can anyone give me some pointers! I have tried using variables (var inside the draw function to call function smileyFace but no luck!</p>
  
  <p>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>function setup() {
    createCanvas(400, 400);
    background(220);
    smileyFace(random(0, 400), random(0, 400));
  }
  
  function draw() {
  
  }
  
  function smileyFace(x, y) {
    fill(250);
    ellipse(x, y, 60, 60);
    fill(255);
    ellipse(x - 10, y - 10, 10, 10);
    ellipse(x + 10, y - 10, 10, 10);
    arc(x, y + 5, 30, 25, 0, PI, CHORD);
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.9.0/p5.js"&gt;&lt;/script&gt;</code></pre>
  </div>
  </div>
  </p>