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