# Why does my code not work

**URL:** <https://discourse.processing.org/t/why-does-my-code-not-work/8394>\
**Category:** Coding Questions\
**Created:** [February 14, 2019, 12:51pm UTC](https://discourse.processing.org/t/why-does-my-code-not-work/8394 "2019-02-14T12:51:35Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![babaramdev](https://avatars.discourse-cdn.com/v4/letter/b/2bfe46/32.png) [@babaramdev](https://discourse.processing.org/u/babaramdev)\
**Post date:** [February 14, 2019, 12:51pm UTC](https://discourse.processing.org/t/why-does-my-code-not-work/8394/1 "2019-02-14T12:51:35Z")

</div>

```auto
let x_vals = []; //List of x-values
let y_vals = [];
let shapeDone = 0; //When shapeDone = 0, the shape has not been completed. When shapeDone = 1, the shape is completed.
let numberOfSides = 0;
let area=0;
var listOfAllCoordinatesz=[];
let areaNotYetMultipliedByHalf = 0;
let perimeter = 0;

function setup() {// Sets up background
  createCanvas(windowWidth, windowHeight);
  background(100);
  clear();
}

function draw() {
  for(int x=0, x++, x<1000 ;){
    ellipse(x , 0, 10, 10);
  }
}

```

```auto
let x_vals = []; //List of x-values
let y_vals = [];
let shapeDone = 0; //When shapeDone = 0, the shape has not been completed. When shapeDone = 1, the shape is completed.
let numberOfSides = 0;
let area=0;
var listOfAllCoordinatesz=[];
let areaNotYetMultipliedByHalf = 0;
let perimeter = 0;

function setup() {// Sets up background
  createCanvas(windowWidth, windowHeight);
  background(100);
  clear();
}

function draw() {
  for(int x=0, x<1000, x++, ;){
    ellipse(x , 0, 10, 10);
  }
}

```

---

<div class="post-metadata">

**Author:** ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)\
**Post date:** [February 15, 2019, 5:01pm UTC](https://discourse.processing.org/t/why-does-my-code-not-work/8394/2 "2019-02-15T17:01:43Z")

</div>

What are you trying to do? What is it doing instead? Are you getting an error message?

Did you mean to paste your code twice? Are there differences between the two sketches?

---

<div class="post-metadata">

**Author:** ![adamherst](https://avatars.discourse-cdn.com/v4/letter/a/a87d85/32.png) [@adamherst](https://discourse.processing.org/u/adamherst)\
**Post date:** [February 16, 2019, 8:49pm UTC](https://discourse.processing.org/t/why-does-my-code-not-work/8394/3 "2019-02-16T20:49:41Z")

</div>

There are a couple of errors with your for() loop:

1. Variables in p5 are declared with ‘var’ not ‘int’

2. The expressions in the for() statement should be separated with ‘;’ not ‘,’ and there should not be a terminating ‘;’
