# Easy function question

**URL:** <https://discourse.nodered.org/t/easy-function-question/35762>\
**Category:** General\
**Created:** [11 November 2020 20:13 UTC](https://discourse.nodered.org/t/easy-function-question/35762 "2020-11-11T20:13:28Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![trombose009](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trombose009/32/30787_2.png) [@trombose009](https://discourse.nodered.org/u/trombose009)\
**Post date:** [11 November 2020 20:13 UTC](https://discourse.nodered.org/t/easy-function-question/35762/1 "2020-11-11T20:13:28Z")

</div>

Hey,

I am using a get method on a http request node to get a temperature value from my heating.  
It ends up in a function:  
msg.payload = [{temp: msg.payload.eta.value[0].$.strValue},{room: "aussen"}]  
return msg  
unfortunately, the value in my array is like this:  
temp: "7.5" (Degrees)  
and not as it should be  
temp: 7.5

So how can I remove these quotation marks?

Greetings

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [11 November 2020 20:19 UTC](https://discourse.nodered.org/t/easy-function-question/35762/2 "2020-11-11T20:19:00Z")

</div>

Surround the assignment value with parseInt()

```auto
msg.payload = [{temp: parseInt(msg.payload.eta.value[0].$.strValue)},{room: "aussen"}]

```

Ps,

Hi, in order to make code more readable and importable it is important to surround your code with three backticks  
`````  
`like this`  
`````

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)

---

<div class="post-metadata">

**Author:** ![trombose009](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trombose009/32/30787_2.png) [@trombose009](https://discourse.nodered.org/u/trombose009)\
**Post date:** [11 November 2020 20:46 UTC](https://discourse.nodered.org/t/easy-function-question/35762/3 "2020-11-11T20:46:00Z")

</div>

thanks, it works

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [11 November 2020 20:49 UTC](https://discourse.nodered.org/t/easy-function-question/35762/4 "2020-11-11T20:49:40Z")

</div>

It has been pointed out to me I should have said parseFloat not parseInt

I mislead you. I'm tired 😉 lol

---

<div class="post-metadata">

**Author:** ![trombose009](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trombose009/32/30787_2.png) [@trombose009](https://discourse.nodered.org/u/trombose009)\
**Post date:** [11 November 2020 21:09 UTC](https://discourse.nodered.org/t/easy-function-question/35762/5 "2020-11-11T21:09:49Z")

</div>

Oh, what Happens If i do parsint?

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [11 November 2020 21:12 UTC](https://discourse.nodered.org/t/easy-function-question/35762/6 "2020-11-11T21:12:34Z")

</div>

parseInt will turn "7.5" into 7  
parseFloat will turn "7.5" into 7.5

---

<div class="post-metadata">

**Author:** ![trombose009](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trombose009/32/30787_2.png) [@trombose009](https://discourse.nodered.org/u/trombose009)\
**Post date:** [11 November 2020 21:26 UTC](https://discourse.nodered.org/t/easy-function-question/35762/7 "2020-11-11T21:26:19Z")

</div>

Ah, of course! I was just wondering... 😛

---

<div class="post-metadata">

**Author:** ![trombose009](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trombose009/32/30787_2.png) [@trombose009](https://discourse.nodered.org/u/trombose009)\
**Post date:** [12 November 2020 11:36 UTC](https://discourse.nodered.org/t/easy-function-question/35762/8 "2020-11-12T11:36:00Z")

</div>

Hey Steve,

I still have the problem, that e.g. 10.8 transforms into 10.  
I do it like this now:

```auto
msg.payload = [{temp: parseFloat(msg.payload.eta.value[0].$.strValue)},{room: "aussen"}]
return msg

```

debugging result looks like this:

 ![out](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/1/a12a3d1652a3485c6c9b8abfbb4c5bd807125f63.png)

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [12 November 2020 11:39 UTC](https://discourse.nodered.org/t/easy-function-question/35762/9 "2020-11-12T11:39:35Z")

</div>

`10,8` is not `10.8`

you will need to replace "," with "."

e.g...

```auto
parseFloat(msg.payload.eta.value[0].$.strValue.replace(',','.').replace(' ',''))

```

---

<div class="post-metadata">

**Author:** ![trombose009](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trombose009/32/30787_2.png) [@trombose009](https://discourse.nodered.org/u/trombose009)\
**Post date:** [12 November 2020 12:05 UTC](https://discourse.nodered.org/t/easy-function-question/35762/10 "2020-11-12T12:05:39Z")

</div>

that's it. thx

---

<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:** [26 November 2020 12:05 UTC](https://discourse.nodered.org/t/easy-function-question/35762/11 "2020-11-26T12:05:48Z")

</div>

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