submission by SSample for logic and functions (View the other submissions)
function setup(){
  var myCanvas = createCanvas(windowWidth,windowHeight); //you must keep this line unmodified
}

function draw() {
  function gumballs(myx, myy) {
      ellipse(myx, myy, 20, 20)
  }
  function gum_stick(me_x, me_y) {
    rect(me_x, me_y, 20, 40)
  }

  var red = color(255, 0, 0)
  var orange = color(255, 128, 0)
  var yellow = color(255, 255, 0)
  var lime = color(0, 255, 0)
  var green = color(100, 190, 100)
  var blue = color(0, 0, 255)
  var purple = color(128, 0, 128)
  var white = color(255)
  var gray = color(128)
  var black = color(0)

    for(x = 20; x < 770; x += 22) {
      if(x%9 == 0) {
        fill(red)
      } else if(x%9 == 1) {
        fill(orange)
      } else if(x%10 == 2) {
        fill(yellow)
      } else if(x%9 == 3) {
        fill(lime)
      } else if(x%9 == 4) {
        fill(green)
      } else if(x%9 == 5) {

     } else if(x%9 == 6) {
        fill(blue)
      } else if(x%9 == 7) {
        fill(purple)
      } else if(x%9 == 8) {
        fill(white)
      } else {
        fill(gray)
      }
      gumballs(x, 350)
      gum_stick(x, 450)
    }
  }