# Help a poor noob - arrays

**URL:** <https://discourse.processing.org/t/help-a-poor-noob-arrays/29505>\
**Category:** Beginners\
**Created:** [April 19, 2021, 9:11pm UTC](https://discourse.processing.org/t/help-a-poor-noob-arrays/29505 "2021-04-19T21:11:09Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![josephh](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/josephh/32/210_2.png) [@josephh](https://discourse.processing.org/u/josephh)\
**Post date:** [April 19, 2021, 9:28pm UTC](https://discourse.processing.org/t/help-a-poor-noob-arrays/29505/2 "2021-04-19T21:28:03Z")

</div>

Hi,

Welcome to the forum! 😉

Your error comes from the fact that you are assigning `stage1` to the variable `fase` before the variable `stage1` has been initialized.

The computer reads your program from top to bottom but in JavaScript it doesn’t give you an error. You can refer to this previous thread on the subject :

> [@We have to claim variables in advance?](https://discourse.processing.org/t/we-have-to-claim-variables-in-advance/29431):
>
> Interestingly, if I claim variable like function setup() { createCanvas(100,100); let pg = createGraphics(100,100); // claim variable like this } function draw() { pg.background(100); image(pg, 0, 0); } when I call pg.background(100), the error occurs “pg is not defined”. But if I claim it in advance like let pg; function setup() { createCanvas(100,100); pg = createGraphics(100,100); // claim variable like this } function draw() { pg.background(100); image(pg, 0, 0); } i…

This is what happens :

1. The JavaScript engine parse your code. Because of [hoisting](https://developer.mozilla.org/en-US/docs/Glossary/Hoisting), it moves the declaration of the `stage1` variable so it’s doing :

```auto
var stage1; // Uninitialized -> undefined

```

1. Then we declare and assign `stage1` to `fase` which is `undefined`:

```auto
var fase = stage1; // -> undefined

```

1. The `stage1` variable gets initialized with the array :

```auto
var stage1 = [
  [‘0’, ‘1’, ‘0’, ‘1’],
  [‘0’, ‘1’, ‘1’, ‘0’],
];

```

But `fase` is still undefined!!

Check out this simple example :

```auto
var a = b;
console.log(a); // Prints undefined

var b = [0, 1];
console.log(a, b); // Prints undefined [0, 1]

```

So you need to assign `stage1` to `fase` after `stage1` has been initialized 😋

---

_[View the full topic](https://discourse.processing.org/t/help-a-poor-noob-arrays/29505)._
