Arrays-
Working with P5.js is an awesome adventure and learning experience. I have been working on a few topics the past couple days and I will begin with an array. An array is a collection of values separated by commas inside square brackets (see picture below).
I wrote my name in the array. I then filled the background color green and used a for loop, which is a counter loop that executes as long as the condition is true. It goes through the array’s index which starts from 0 and counts up. I then decided on a text size and then used the pre-defined term text to print each string in the array with a specific space between each other and specific location.
Functions-
I then created a new code that defines and uses two functions (see picture below)
one function is mousePressed and the other is keyPressed. They both are events and get executed either when the user presses on the mouse or presses on the key that is indicated, for this example it is the left and right arrow keys. When the mouse is pressed in this code the background color changes as well as the ellipse color. When the left and right arrow keys are pressed the rectangle moves left by 100 pixels and right by 50 pixels.
Methods-Functions in an object
The next code I have written was an object that had at least one function (see pic below)
I created two objects with two functions one will move the objects and the other will display them. By creating these functions along in the object helps minimize writing verbose code which in the end makes it easier to understand and make the code modular.
Boolean variable with event driven function-
I then added a Boolean variable with an event driven function (see pic below)

so as you can see I have a Boolean variable which states if any key is pressed then there will be a change in background color and a yellow ellipse will appear at specific location. As well if the mouse is pressed there will be an event that takes place that will switch the background color again and a blue ellipse will appear in a specific location. This was very interesting and exciting to see how these functions and variables interact with in the code.