Callback function argument

I am writing a program that connects P5 with the HTML DOM. I want to have a HTML button when pressed pass along an argument to a function I created. I know I can add an event and callback function to a variable. I am wondering if it possible to add an argument with the callback function.

This is what I have

HTML
Button

P5

let btn;
function setup(){
btn = select("#btn");
btn.mousePressed(myFunction);
}

function myFunction(){
}

What I want to do

let btn;
function setup(){
btn = select("#btn");
btn.mousePressed(myFunction(myArg));
}
function myFunction(arg){
x = x + arg;
}

Any assistance would be appreciated

If myArg is determined when you call mousePressed() you can use bind():
btn.mousePressed(myFunction.bind(null, myArg));

Otherwise you should declare myArg as a global variable.