# \[SOLVED\] Undefined Error

**URL:** <https://discourse.processing.org/t/solved-undefined-error/7176>\
**Category:** Coding Questions\
**Created:** [January 4, 2019, 5:47pm UTC](https://discourse.processing.org/t/solved-undefined-error/7176 "2019-01-04T17:47:30Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Quillbert1](https://avatars.discourse-cdn.com/v4/letter/q/f475e1/32.png) [@Quillbert1](https://discourse.processing.org/u/Quillbert1)\
**Post date:** [January 4, 2019, 5:47pm UTC](https://discourse.processing.org/t/solved-undefined-error/7176/1 "2019-01-04T17:47:30Z")

</div>

I am having an issue with some code. Whenever I run it, i get an error saying Population is undefined in setup.  
The code is at the github link below.

> **[Quillbert/Platformer-AI](https://github.com/Quillbert/Platformer-AI)**
>
> Contribute to Quillbert/Platformer-AI development by creating an account on GitHub.

---

<div class="post-metadata">

**Author:** ![Architector\_4](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/architector_4/32/813_2.png) [@Architector\_4](https://discourse.processing.org/u/Architector_4)\
**Post date:** [January 4, 2019, 6:41pm UTC](https://discourse.processing.org/t/solved-undefined-error/7176/2 "2019-01-04T18:41:23Z")

</div>

I think it has to do with the order of things that you load within `index.html`. You load `sketch.js` before `Population.js`, so at the time you load `sketch.js` there was nothing before it that defined `Population.js`.

I suggest putting the `<script language="javascript" type="text/javascript" src="sketch.js"></script>` line at the end of the `<script...` wall instead.

---

<div class="post-metadata">

**Author:** ![Quillbert1](https://avatars.discourse-cdn.com/v4/letter/q/f475e1/32.png) [@Quillbert1](https://discourse.processing.org/u/Quillbert1)\
**Post date:** [January 4, 2019, 6:50pm UTC](https://discourse.processing.org/t/solved-undefined-error/7176/3 "2019-01-04T18:50:08Z")

</div>

That didn’t seem to fix it. ☹

---

<div class="post-metadata">

**Author:** ![Quillbert1](https://avatars.discourse-cdn.com/v4/letter/q/f475e1/32.png) [@Quillbert1](https://discourse.processing.org/u/Quillbert1)\
**Post date:** [January 4, 2019, 7:08pm UTC](https://discourse.processing.org/t/solved-undefined-error/7176/4 "2019-01-04T19:08:31Z")

</div>

I have found the problem! I was changing the code from java, and instead of `var` I accidentally said the class name.

---

<div class="post-metadata">

**Author:** ![Architector\_4](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/architector_4/32/813_2.png) [@Architector\_4](https://discourse.processing.org/u/Architector_4)\
**Post date:** [January 4, 2019, 7:09pm UTC](https://discourse.processing.org/t/solved-undefined-error/7176/5 "2019-01-04T19:09:39Z")

</div>

Oh. Glad that thing got resolved.

Care to change thread title to say [Solved] or something, so that people wouldn’t start writing more possible solutions?
