Accessing local elements in another function in p5js

I am pretty new to p5js and website building, I am doing a project for uni-related to emotion sensing Ai, basically, it generates recipes based on your emotion. I have built a random recipe generator but I need to append the ingredient (for eg. chamomile for neutral)to the original recipe.

1.-this is the webpage and the random recipe is generated by clicking on the generate recipe button.

2.-this is the code for generating the recipes I am using a CSV to access the data

3.-is there I can access them here above where (this is in the draw function) i can append the ingredients according to the emotion sensed for which the code is also in the draw function.


(since i am a new user i cannot upload more than one images so complied all of them,the code screenshots are are numbered with the numbers of the explanation)