Below is the full source code from this demo. You can copy and paste this into P5JS or you can open it directly here.
function setup() {
createCanvas(500, 500); myXPos = 200; console.log("I am in the setup function an myXPos = " + myXPos); fill("blue"); drawBox(myXPos, 200, 50, 70); fill("red"); drawBox(myXPos+100, 0, 200, 500);}
function drawBox (a,b,c,d) { console.log ("I am in the drawBox function and myXPos = " + a); rect(a,b,c,d); }