# Hello how to division msg.payload value /10

**URL:** <https://discourse.nodered.org/t/hello-how-to-division-msg-payload-value-10/82481>\
**Category:** Dashboard\
**Tags:** function-node\
**Created:** [31 October 2023 06:40 UTC](https://discourse.nodered.org/t/hello-how-to-division-msg-payload-value-10/82481 "2023-10-31T06:40:28Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![ShinDongHen](https://avatars.discourse-cdn.com/v4/letter/s/ac8455/32.png) [@ShinDongHen](https://discourse.nodered.org/u/ShinDongHen)\
**Post date:** [31 October 2023 06:40 UTC](https://discourse.nodered.org/t/hello-how-to-division-msg-payload-value-10/82481/1 "2023-10-31T06:40:28Z")

</div>

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/d/a/dab27769724a9e0238ba5f10847d28ef41c96464.png)

hello  
I would like to inquire about a script issue in Function Block.  
I've never done a script before...  
The value of msg.payload is 203.  
I want to divide by 20.3.  
Please advise.

Please help.  
Thank you so much for your interest.

---

<div class="post-metadata">

**Author:** ![krambriw](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/krambriw/32/5429_2.png) [@krambriw](https://discourse.nodered.org/u/krambriw)\
**Post date:** [31 October 2023 06:52 UTC](https://discourse.nodered.org/t/hello-how-to-division-msg-payload-value-10/82481/2 "2023-10-31T06:52:01Z")

</div>

You are receiving an array with a single element in the msg.payload

You could test this code:

let test = msg.payload[0]/10;  
node.warn(test);

---

<div class="post-metadata">

**Author:** ![ShinDongHen](https://avatars.discourse-cdn.com/v4/letter/s/ac8455/32.png) [@ShinDongHen](https://discourse.nodered.org/u/ShinDongHen)\
**Post date:** [31 October 2023 07:04 UTC](https://discourse.nodered.org/t/hello-how-to-division-msg-payload-value-10/82481/3 "2023-10-31T07:04:00Z")

</div>

vary vary thank you

---

<div class="post-metadata">

**Author:** ![ShinDongHen](https://avatars.discourse-cdn.com/v4/letter/s/ac8455/32.png) [@ShinDongHen](https://discourse.nodered.org/u/ShinDongHen)\
**Post date:** [31 October 2023 09:21 UTC](https://discourse.nodered.org/t/hello-how-to-division-msg-payload-value-10/82481/4 "2023-10-31T09:21:55Z")

</div>

I'm leaving a message because I want to ask a question again.  
How do I change the array value to /10?  
Thanks for your reply.

---

<div class="post-metadata">

**Author:** ![dynamicdave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dynamicdave/32/96_2.png) [@dynamicdave](https://discourse.nodered.org/u/dynamicdave)\
**Post date:** [31 October 2023 09:49 UTC](https://discourse.nodered.org/t/hello-how-to-division-msg-payload-value-10/82481/5 "2023-10-31T09:49:16Z")

</div>

Try this in a function node...

```auto
let test = msg.payload[0]/10;
msg.payload = test;
return msg;

```

Not sure from your question whether you want to divide the first element of the array by 10 and pass that SINGLE value on in a new 'msg.payload' to the next part of your flow OR replace the first element in the array and pass the WHOLE of the original array on?

If you want to do the latter, try this...

```auto
msg.payload[0] = msg.payload[0]/10;
return msg;

```

---

<div class="post-metadata">

**Author:** ![ShinDongHen](https://avatars.discourse-cdn.com/v4/letter/s/ac8455/32.png) [@ShinDongHen](https://discourse.nodered.org/u/ShinDongHen)\
**Post date:** [31 October 2023 11:54 UTC](https://discourse.nodered.org/t/hello-how-to-division-msg-payload-value-10/82481/6 "2023-10-31T11:54:50Z")

</div>

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/7/678828b2395be5d1739cf56a97016671ea407790.png)  
온도 = temp

thank you very very much ~.~!!!!!

---

<div class="post-metadata">

**Author:** ![smanjunath211](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/smanjunath211/32/95742_2.png) [@smanjunath211](https://discourse.nodered.org/u/smanjunath211)\
**Post date:** [31 October 2023 12:08 UTC](https://discourse.nodered.org/t/hello-how-to-division-msg-payload-value-10/82481/7 "2023-10-31T12:08:12Z")

</div>

using change node

```auto
[{"id":"88097a8bc88ab7c2","type":"inject","z":"f0ae706f0b39513f","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"203","payloadType":"num","x":450,"y":570,"wires":[["1caf47266b526982"]]},{"id":"1caf47266b526982","type":"change","z":"f0ae706f0b39513f","name":"Divide input value by 10","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload/10","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":670,"y":570,"wires":[["699141205d222fd0"]]},{"id":"699141205d222fd0","type":"debug","z":"f0ae706f0b39513f","name":"debug 438","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":910,"y":570,"wires":[]}]

```

---

<div class="post-metadata">

**Author:** ![ShinDongHen](https://avatars.discourse-cdn.com/v4/letter/s/ac8455/32.png) [@ShinDongHen](https://discourse.nodered.org/u/ShinDongHen)\
**Post date:** [31 October 2023 12:17 UTC](https://discourse.nodered.org/t/hello-how-to-division-msg-payload-value-10/82481/8 "2023-10-31T12:17:55Z")

</div>

thank you very very much

---

<div class="post-metadata">

**Author:** ![ShinDongHen](https://avatars.discourse-cdn.com/v4/letter/s/ac8455/32.png) [@ShinDongHen](https://discourse.nodered.org/u/ShinDongHen)\
**Post date:** [31 October 2023 12:20 UTC](https://discourse.nodered.org/t/hello-how-to-division-msg-payload-value-10/82481/9 "2023-10-31T12:20:48Z")

</div>

thank you very very much

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [30 November 2023 12:21 UTC](https://discourse.nodered.org/t/hello-how-to-division-msg-payload-value-10/82481/10 "2023-11-30T12:21:20Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
