# Need help correcting this converted P5.js code

**URL:** <https://discourse.processing.org/t/need-help-correcting-this-converted-p5-js-code/23804>\
**Category:** Beginners\
**Created:** [September 11, 2020, 8:42pm UTC](https://discourse.processing.org/t/need-help-correcting-this-converted-p5-js-code/23804 "2020-09-11T20:42:16Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![coreyep](https://avatars.discourse-cdn.com/v4/letter/c/f04885/32.png) [@coreyep](https://discourse.processing.org/u/coreyep)\
**Post date:** [September 11, 2020, 8:42pm UTC](https://discourse.processing.org/t/need-help-correcting-this-converted-p5-js-code/23804/1 "2020-09-11T20:42:16Z")

</div>

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 () {  
background = loadImage(“web\_background\_2.gif” );  
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.

 ![Screen Shot 2020-09-11 at 4.41.13 PM](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/3/32df051b9e4a47f02598b26a2d6827d156d35669.png)

---

<div class="post-metadata">

**Author:** ![alefnull](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/alefnull/32/10561_2.png) [@alefnull](https://discourse.processing.org/u/alefnull)\
**Post date:** [September 11, 2020, 9:35pm UTC](https://discourse.processing.org/t/need-help-correcting-this-converted-p5-js-code/23804/2 "2020-09-11T21:35:08Z")

</div>

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](https://p5js.org/reference/#/p5/function)

---

<div class="post-metadata">

**Author:** ![coreyep](https://avatars.discourse-cdn.com/v4/letter/c/f04885/32.png) [@coreyep](https://discourse.processing.org/u/coreyep)\
**Post date:** [September 12, 2020, 2:33am UTC](https://discourse.processing.org/t/need-help-correcting-this-converted-p5-js-code/23804/3 "2020-09-12T02:33:11Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![alefnull](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/alefnull/32/10561_2.png) [@alefnull](https://discourse.processing.org/u/alefnull)\
**Post date:** [September 13, 2020, 5:52pm UTC](https://discourse.processing.org/t/need-help-correcting-this-converted-p5-js-code/23804/4 "2020-09-13T17:52:09Z")

</div>

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