xxxxxxxxxx
26
let podiums = [];
let largestpodium = 0;
let smallestpodium = 0;
function setup(){
createCanvas(400, 400)
for (i = 0; i < 20; i++){
podiums.push(0);
}
}
function draw(){
background(220);
line(0, 100, width, 100)
for (let i = 0; i < podiums.length; i++){
if (random() > 0.5){podiums[i]+=1};
if (podiums[i] > podiums[largestpodium]){largestpodium = i;}
if (podiums[i] < podiums[smallestpodium]){smallestpodium = i;}
if (i === largestpodium){fill('green');}
else if (i === smallestpodium) {fill('red');}
else {fill('white');}
rect(width/podiums.length*i, height - podiums[i], width/podiums.length, podiums[i]);
if(podiums[i] >= 300){text(podiums[largestpodium]-podiums[smallestpodium], width/2, 20);noLoop();}
}
}