# Syntax Error in geometry.html

**URL:** <https://forum.kirupa.com/t/syntax-error-in-geometry-html/658429>\
**Category:** programming\
**Created:** [April 27, 2023, 3:00pm UTC](https://forum.kirupa.com/t/syntax-error-in-geometry-html/658429 "2023-04-27T15:00:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Willwrtr](https://avatars.discourse-cdn.com/v4/letter/w/ad7895/32.png) [@Willwrtr](https://forum.kirupa.com/u/Willwrtr)\
**Post date:** [April 27, 2023, 3:00pm UTC](https://forum.kirupa.com/t/syntax-error-in-geometry-html/658429/1 "2023-04-27T15:00:26Z")

</div>

URL in question: [Writings](https://sagebrushtidbits.com/geometry.html)

I have a syntax error and an undefined variable error in a short piece of code. I’ve posted the code and an run-copy of it on the above link of mine, under game program errors.  
If anyone can direct me on how to correct these, I’d appreciate it greatly. I’ve also published an ALT attempt I can’t get to work as it should, also listed on that web page selection. Thanks!

---

<div class="post-metadata">

**Author:** ![kirupa](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/kirupa/32/11616_2.png) [@kirupa](https://forum.kirupa.com/u/kirupa)\
**Post date:** [April 27, 2023, 3:48pm UTC](https://forum.kirupa.com/t/syntax-error-in-geometry-html/658429/2 "2023-04-27T15:48:30Z")

</div>

Hi Will - where is the error? I opened the Game Program that you have listed, and I am not seeing any error show up in the console:

 ![image](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/8/6865360628b274e99ef5f2106b3ea1c42a831a00.jpeg)

---

<div class="post-metadata">

**Author:** ![PAEz](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/paez/32/19607_2.png) [@PAEz](https://forum.kirupa.com/u/PAEz)\
**Post date:** [May 8, 2023, 3:53pm UTC](https://forum.kirupa.com/t/syntax-error-in-geometry-html/658429/3 "2023-05-08T15:53:16Z")

</div>

Ooops, I forgot to answer this one.  
The problem is to do with you `moveGuy` variable. First you declare it in window.onload and then you redeclare it late whilst trying to add one to it in the canvas click event `var moveGuy = moveGuy + 1; `. So to fix it you need to change the second on to `moveGuy = moveGuy + 1;` so your not redeclaring it but using the one you declared earlier. When you originaly declare `moveGuy` you need to set its initial value to 0 or its initial value will be undefined and undefined plus one euqals NaN. Heres a version with the fixes… [JS Bin - Collaborative JavaScript Debugging](https://jsbin.com/gawibajiju/edit?html,css,js,output)

And you seem to have removed the other error where you where using JQuery without including jquery.
