Another possibility, especially if the functions require various combinations of numbers and types of arguments, is to create an object, with the names of the functions as strings that serve as keys, and the types of arguments, as Arrays of strings associated with each key. Then choose randomly from the keys in the object, and use the Array of argument types associated with that key to assemble an appropriate function call. It may be complicated, but it could be fun.
EDIT (2x on November 22, 2021):
For yet another strategy, try the code below. It randomly chooses functions paired with their arguments.
// three functions that draw shapes
function rect_maker(x, y, r, g, b) {
fill(r, g, b);
rect(x, y, 40, 40);
}
function ellipse_maker(x, y, w, h) {
fill(random(256), random(256), random(256), random(256));
ellipse(x, y, w, h);
}
function line_maker() {
line(random(width), random(height), random(width), random(height));
}
function setup() {
createCanvas(240, 240);
strokeWeight(4);
stroke(0);
frameRate(1);
rectMode(CENTER);
}
function draw() {
// array of arrays of functions with randomly-valued arguments for each
let funcs_and_args = [
[rect_maker, [random(width), random(height), random(256), random(256), random(256)]],
[ellipse_maker, [random(width), random(height),random(width / 4), random(height / 4)]],
[line_maker, []]
];
// randomly choose a function with arguments pair
let f_and_a = random(funcs_and_args);
// call the chosen function, passing its arguments to it; use destructuring
f_and_a[0](...f_and_a[1]);
}
To understand this line …
f_and_a[0](...f_and_a[1]);
… see …