Functions
Shapes & Canvas
Variables & Data
Logic & Loops
Debugging & Animation
100

What is a function that runs once when a p5.js sketch starts?

Function setup()

100

What command creates a drawing area that is 400 pixels wide and 300 pixels tall?

createCanvas(400, 300)

100

Which keyword is used to create a variable in JavaScript?

Let

100

What statement allows a program to make decisions?

An if statement

100

What tool helps programmers find errors in p5.js?

The Console

200

What is a function that runs continuously in a loop?

Function draw()

200

What are the coordinates of the top-left corner of the canvas?

(0,0)

200

What variable stores the mouse's x-position?

mouseX

200

What symbol checks if two values are equal?

==

200

What does console.log() do?

Prints messages to the console.

300

What is a function that runs when the mouse is clicked?

Function mousePressed()

300

Which function draws a rectangle?

rect()

300

What variable stores the mouse's y-position?

mouseY

300

What does a loop do?

Repeats code

300

What might happen if there is a syntax error in your code?

The program may not run.

400

Which is a function that changes the background color of the canvas?

Function background()

400

What shape does ellipse(50, 50, 40, 40) create?

An oval

400

What type of data can only be true or false?

Boolean

400

What happens when an if statement's condition is true?

The code inside the if statement runs.

400

What does cloudX += 0.5; typically control in an animation?

Movement of an object.

500

Which is a function that displays words on the canvas?

Function text()

500

Which function removes the outline around shapes?

noStroke()

500

What function generates a random number between two values?

random()

500

Give an example of when you might use a loop in animation.

To continuously move an object across the screen.

500

Why are comments and indentation important?

They make code easier to read and understand.