# Where is the error in my code?

**URL:** https://discourse.processing.org/t/where-is-the-error-in-my-code/8878
**Category:** Coding Questions
**Created:** [March 3, 2019, 6:01am UTC](https://discourse.processing.org/t/where-is-the-error-in-my-code/8878 "2019-03-03T06:01:35Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![ximi](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/ximi/32/3939_2.png) [@ximi](https://discourse.processing.org/u/ximi)
#### Post date: [March 3, 2019, 6:01am UTC](https://discourse.processing.org/t/where-is-the-error-in-my-code/8878/1 "2019-03-03T06:01:35Z")

</div>

![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/6/6c77181279374eb7765ad3e9fd1e6e8f59df022d.png)  
[https://editor.p5js.org/eternity95097@gmail.com/sketches/TvAwrnaMB](https://editor.p5js.org/eternity95097@gmail.com/sketches/TvAwrnaMB)

---

<div class="post-metadata">

### Author: ![kll](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kll/32/964_2.png) [@kll](https://discourse.processing.org/u/kll)
#### Post date: [March 3, 2019, 6:22am UTC](https://discourse.processing.org/t/where-is-the-error-in-my-code/8878/2 "2019-03-03T06:22:28Z")

</div>

pls. check out the examples,  
[https://p5js.org/examples/arrays-array-2d.html](https://p5js.org/examples/arrays-array-2d.html)

a more simplified example:

```auto
let myarray = [];
let maxarray =5;

function setup() {
  createCanvas(200,200);
  for (let x = 0; x < maxarray; x++) {
    myarray[x] = []; // create nested array
    for (let y = 0; y < maxarray; y++) myarray[x][y] = x*y;
  }
  noLoop(); // Run once and stop
}

function draw() {
	 for (let x = 0; x < maxarray; x++) console.log(myarray[x]);
}

```

prints:

- [0, 0, 0, 0, 0]
- [0, 1, 2, 3, 4]
- [0, 2, 4, 6, 8]
- [0, 3, 6, 9, 12]
- [0, 4, 8, 12, 16]

while that works i think the problem in your code is also with the  
[x/len]  
there are only integer number 0 …N allowed ( matrix index )  
but you seem to calculate ? floats  
and i worry they are not understood as int index.
