# Hello all , I want your help in adding two consecutive msg.payload array\[\] and then finding running average for latest value + stored value

**URL:** <https://discourse.nodered.org/t/hello-all-i-want-your-help-in-adding-two-consecutive-msg-payload-array-and-then-finding-running-average-for-latest-value-stored-value/58513>\
**Category:** General\
**Created:** [17 February 2022 07:36 UTC](https://discourse.nodered.org/t/hello-all-i-want-your-help-in-adding-two-consecutive-msg-payload-array-and-then-finding-running-average-for-latest-value-stored-value/58513 "2022-02-17T07:36:23Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [17 February 2022 11:03 UTC](https://discourse.nodered.org/t/hello-all-i-want-your-help-in-adding-two-consecutive-msg-payload-array-and-then-finding-running-average-for-latest-value-stored-value/58513/4 "2022-02-17T11:03:51Z")

</div>

Welcome to the forum @developedbymayur

In order to make code readable and usable it is necessary to surround your code with three backticks (also known as a left quote or backquote `````)

````auto
``` 
   code goes here 
```

````

You can edit and correct your post by clicking the pencil ✏ icon.

See this post for more details - [How to share code or flow json](https://discourse.nodered.org/t/how-to-share-code-or-flow-json/506)

To debug your code you can add node.warn() statements to show intermediate results in the debug pane. For example, after the `total += ` line you could add

```auto
node.warn(`total = ${total}`)

```

By using that technique you can follow the flow through and see where it is failing.

---

_[View the full topic](https://discourse.nodered.org/t/hello-all-i-want-your-help-in-adding-two-consecutive-msg-payload-array-and-then-finding-running-average-for-latest-value-stored-value/58513)._
