# Some problem in pushing blocks in p5.js sketch

**URL:** <https://discourse.processing.org/t/some-problem-in-pushing-blocks-in-p5-js-sketch/21780>\
**Category:** Coding Questions\
**Created:** [June 11, 2020, 4:35pm UTC](https://discourse.processing.org/t/some-problem-in-pushing-blocks-in-p5-js-sketch/21780 "2020-06-11T16:35:01Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nisss](https://avatars.discourse-cdn.com/v4/letter/n/ad7895/32.png) [@Nisss](https://discourse.processing.org/u/Nisss)\
**Post date:** [June 11, 2020, 4:35pm UTC](https://discourse.processing.org/t/some-problem-in-pushing-blocks-in-p5-js-sketch/21780/1 "2020-06-11T16:35:01Z")

</div>

[https://editor.p5js.org/Nis\_Collect/sketches/eeOTXD\_D2](https://editor.p5js.org/Nis_Collect/sketches/eeOTXD_D2)  
☝☝☝☝☝☝☝☝☝☝☝☝☝☝☝☝☝☝☝☝  
Above is the link of my code…  
I want to push a new block every time i click. But my code has some problem which makes it “doesn’t seem to work well”…  
According to me…I couldn’t use proper values for mouseX and mouseY…please please please check and please recommended me the best and the most proper answer.  
Someone please please please suggest me, whete am i getting wrong in my code…and also how could i correct any problem if there in my code.

Please please please please please someone help

---

<div class="post-metadata">

**Author:** ![TheWizardBear](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/thewizardbear/32/3552_2.png) [@TheWizardBear](https://discourse.processing.org/u/TheWizardBear)\
**Post date:** [June 11, 2020, 7:08pm UTC](https://discourse.processing.org/t/some-problem-in-pushing-blocks-in-p5-js-sketch/21780/2 "2020-06-11T19:08:26Z")

</div>

You forgot the `new` keyword on line 59.  
It should be:

```javascript
b.push(new B());

```

If you don’t use `new` then you are just calling the function and, as the function doesn’t return anything, you will end up pushing `undefined` to your array (`b`).

---

<div class="post-metadata">

**Author:** ![Nisss](https://avatars.discourse-cdn.com/v4/letter/n/ad7895/32.png) [@Nisss](https://discourse.processing.org/u/Nisss)\
**Post date:** [June 12, 2020, 1:01am UTC](https://discourse.processing.org/t/some-problem-in-pushing-blocks-in-p5-js-sketch/21780/3 "2020-06-12T01:01:35Z")

</div>

Ya ok…Thanks…Its working now…  
But still if you try and run my sketch you will also experience something wrong. The blocks aren’t getting inserted at the proper mouseX and mouseY.  
Please please please check it and answer me please

---

<div class="post-metadata">

**Author:** ![Nisss](https://avatars.discourse-cdn.com/v4/letter/n/ad7895/32.png) [@Nisss](https://discourse.processing.org/u/Nisss)\
**Post date:** [June 12, 2020, 10:32am UTC](https://discourse.processing.org/t/some-problem-in-pushing-blocks-in-p5-js-sketch/21780/4 "2020-06-12T10:32:12Z")

</div>

Sir please respond…please please please.please please please.please please please
