xxxxxxxxxx
24
let randomCounts;
function setup() {
createCanvas(640, 240);
randomCounts = [];
for (let i = 0; i < 20; i++){
randomCounts.push(0);
}
}
function draw() {
background(255);
// pick a random number
let index = int(random(randomCounts.length));
// increase the count
randomCounts[index]++;
stroke(0);
fill(175);
let w = width/randomCounts.length;
for(let x = 0; x < randomCounts.length; x++){
rect(x*w, height-randomCounts[x], w-1, randomCounts[x])
}
}