Need help correcting this converted P5.js code

I converted my Java processing code to P5.js, which I pasted below but my notifications box is telling me that I am missing semicolons for “static final let NUM_LINES = 10;” and all of my “let x_(let t) {” and “let y_1(let t) {”. I am not sure where these missing semicolons are supposed to go though:

<
// y = 5x
// x = 5t
// y = 3t + 3
let background;
static final let NUM_LINES = 10;
let t;
let r = 0;

function setup () {
createCanvas(740, 416);
colorMode (HSB,360);
}

function draw() {
background(background);
stroke(r,360,260);
strokeWeight(5);

translate(width/2, height/2);

for (let i = 0; i < NUM_LINES; i++) {
line(x1(t + i), y1(t + i), x2(t + i), y2(t + i));
}
t+= 0.5;
}

let x1(let t) {
return sin(t / 10) * 100 + sin(t / 5) * 20 + sin(t / 5) * 50 + sin(t) * 2 + cos(t) * 10;
}

let y1(let t) {
return cos(-t / 10) * 100 + sin(t / 5) * 50;
}

let x2(let t) {
return sin(t / 10) * 200 + sin(t) * 2 + cos(t) * 10;
}

let y2(let t) {
return cos(t / 20) * 200 + cos(t / 12) * 20;
}

Here’s a screenshot to help.

i’m not all that well-versed in P5 or JS in general, but i believe declaring a function requires the “function” keyword.

so instead of something like “let x1(let t) {” maybe try “function x1(let t) {”?

again, i honestly don’t know if this is a solution, but it’s my best guess based on my limited knowledge. hope it helps!

https://p5js.org/reference/#/p5/function

just made that change and it did the trick. Thank you for this.

1 Like

no problem, glad (and honestly a little surprised) that it worked!