function setup(){
createCanvas(500,500);
background(255);
}
function draw(){
for(let x=0; x<500; x+=50){
for(let y=0; y<500; y+=50){
rect(x,y,25,25);
for(let x=25; x<500; x+=50){
for(let y=25; y<500; y+=50){
rect(x,y,25,25);
fill(0)
}
}
}
}
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.1.9/p5.min.js"></script>