# Why doesnt this work?

**URL:** <https://forum.makecode.com/t/why-doesnt-this-work/12455>\
**Category:** Help\
**Created:** [March 2, 2022, 6:09pm UTC](https://forum.makecode.com/t/why-doesnt-this-work/12455 "2022-03-02T18:09:57Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![hasanchik](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/hasanchik/32/5885_2.png) [@hasanchik](https://forum.makecode.com/u/hasanchik)\
**Post date:** [March 2, 2022, 6:09pm UTC](https://forum.makecode.com/t/why-doesnt-this-work/12455/1 "2022-03-02T18:09:57Z")

</div>

This is frustrating me a lot.  
“Dereferencing null/undefined value.”

```auto
let walls: boolean[][]
for (let x = -1; x < 31; x++) {
    for (let y = -1; y < 31; y++) {
        walls[x][y] = tiles.tileAtLocationIsWall(tiles.getTileLocation(x, y))
    }
}

```

---

<div class="post-metadata">

**Author:** ![richard](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/richard/32/5417_2.png) [@richard](https://forum.makecode.com/u/richard)\
**Post date:** [March 2, 2022, 6:11pm UTC](https://forum.makecode.com/t/why-doesnt-this-work/12455/2 "2022-03-02T18:11:43Z")

</div>

You’re never assigning anythings to `walls`. Try this:

```typescript
let walls: boolean[][] = [];
for (let x = 0; x < 31; x++) {
    walls[x] = [];
    for (let y = 0; y < 31; y++) {
        walls[x][y] = tiles.tileAtLocationIsWall(tiles.getTileLocation(x, y))
    }
}

```

---

<div class="post-metadata">

**Author:** ![hasanchik](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/hasanchik/32/5885_2.png) [@hasanchik](https://forum.makecode.com/u/hasanchik)\
**Post date:** [March 2, 2022, 6:13pm UTC](https://forum.makecode.com/t/why-doesnt-this-work/12455/3 "2022-03-02T18:13:49Z")

</div>

Lightning quick response! Thanks alot!!
