# New line constant with text variable

**URL:** <https://discourse.nodered.org/t/new-line-constant-with-text-variable/88462>\
**Category:** General\
**Created:** [3 June 2024 10:37 UTC](https://discourse.nodered.org/t/new-line-constant-with-text-variable/88462 "2024-06-03T10:37:32Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sirhc](https://avatars.discourse-cdn.com/v4/letter/s/b77776/32.png) [@Sirhc](https://discourse.nodered.org/u/Sirhc)\
**Post date:** [3 June 2024 10:37 UTC](https://discourse.nodered.org/t/new-line-constant-with-text-variable/88462/1 "2024-06-03T10:37:32Z")

</div>

hello

I am trying output some text from a function to a text node using:

let var1 = "";

var1 = var1 + "new text \r \n";

var1 = var1 + "new text 2 \r \n";

msg.payload = var1;  
return msg;

It works fine and var1 displays in the text node, but I need it to add a new line constant between new text and new text 2, so far I am seeing all new text and new text 2 on the same line

Any thoughts?

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [3 June 2024 10:39 UTC](https://discourse.nodered.org/t/new-line-constant-with-text-variable/88462/2 "2024-06-03T10:39:20Z")

</div>

Hi @Sirhc

Which text node are you referring to? Is this Node-RED Dashboard? FlowFuse Dashboard? Or something else entirely?

---

<div class="post-metadata">

**Author:** ![Sirhc](https://avatars.discourse-cdn.com/v4/letter/s/b77776/32.png) [@Sirhc](https://discourse.nodered.org/u/Sirhc)\
**Post date:** [3 June 2024 10:39 UTC](https://discourse.nodered.org/t/new-line-constant-with-text-variable/88462/3 "2024-06-03T10:39:42Z")

</div>

This is in the node red dashboard, using the text node.

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [3 June 2024 10:43 UTC](https://discourse.nodered.org/t/new-line-constant-with-text-variable/88462/4 "2024-06-03T10:43:54Z")

</div>

Ok, I don't really know, but I thought it was `<br>` for new line.

(Sorry, I'll go away)

---

<div class="post-metadata">

**Author:** ![Sirhc](https://avatars.discourse-cdn.com/v4/letter/s/b77776/32.png) [@Sirhc](https://discourse.nodered.org/u/Sirhc)\
**Post date:** [3 June 2024 10:45 UTC](https://discourse.nodered.org/t/new-line-constant-with-text-variable/88462/5 "2024-06-03T10:45:15Z")

</div>

Ah it is   
! thank you very much!

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [3 June 2024 10:46 UTC](https://discourse.nodered.org/t/new-line-constant-with-text-variable/88462/6 "2024-06-03T10:46:24Z")

</div>

If it was me, please mark it to help anyone else with the same problem.

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [3 June 2024 10:50 UTC](https://discourse.nodered.org/t/new-line-constant-with-text-variable/88462/7 "2024-06-03T10:50:40Z")

</div>

Just a comment that instead of

```auto
let var1 = "";
var1 = var1 + "new text";
var1 = var1 + "<br>";
var1 = var1 + "new text 2";
msg.payload = var1;

```

Your function could be

```auto
msg.payload = "new text" + "<br>" + "new text 2"

```

---

<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:** [17 June 2024 10:51 UTC](https://discourse.nodered.org/t/new-line-constant-with-text-variable/88462/8 "2024-06-17T10:51:11Z")

</div>

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