top of page

DEBUG: Declaring Variables

Why doesn’t this sketch work? Duplicate and rewrite it so that a circle draws on the canvas. Try to come up with at least two solutions. Add comments to your code explaining your answers.

This sketch doesn't work because variable 'xpos' wasn't declared!


Debugging it...

Option 1: Declare 'xpos' before the setup() function, and initialize the value within setup()

See the sketch here



Option 2: Declare and initialize 'xpos' at the same time!

See the sketch here

5 views0 comments

Recent Posts

See All
bottom of page