# Why does the error comes even though the function is defined?

**URL:** <https://discourse.processing.org/t/why-does-the-error-comes-even-though-the-function-is-defined/19440>\
**Category:** Libraries\
**Created:** [April 5, 2020, 5:59pm UTC](https://discourse.processing.org/t/why-does-the-error-comes-even-though-the-function-is-defined/19440 "2020-04-05T17:59:37Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rohit](https://avatars.discourse-cdn.com/v4/letter/r/41988e/32.png) [@Rohit](https://discourse.processing.org/u/Rohit)\
**Post date:** [April 5, 2020, 5:59pm UTC](https://discourse.processing.org/t/why-does-the-error-comes-even-though-the-function-is-defined/19440/1 "2020-04-05T17:59:37Z")

</div>

here is the link to my project [https://editor.p5js.org/rohitgokul817/sketches/yhOcLU2KX](https://editor.p5js.org/rohitgokul817/sketches/yhOcLU2KX)

please help me to figure out the error the function is defined buti am getting the error Uncaught ReferenceError: antsweets is not defined (sketch: line 164)

please help me as soon as possible

---

<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:** [April 5, 2020, 6:01pm UTC](https://discourse.processing.org/t/why-does-the-error-comes-even-though-the-function-is-defined/19440/2 "2020-04-05T18:01:40Z")

</div>

Try running Edit \> Tidy Code.

You are almost certainly missing a } higher up, and so some of your functions are nested inside later functions.

It is impossible to tell, though, because your indenting is so messy.
