New line funktion node

I am working on a function node where I as a payload combine a lot of variables, this becomes a single long text. I am now trying to find if you can write something between + to get a new line where I want it. Have tested and

....

but nothing seems to work.

Not really clear what you are trying to achieve, can you post some examples?

If you are wanting more flexibility when working with strings in a function node though, you may want to look at Template literals (Template strings) - JavaScript | MDN (mozilla.org).

These let you work with multiple lines and embedded JavaScript.

let a = 5;
let b = 10;
console.log(`Fifteen is ${a + b} and not ${2 * a + b}.`);

Can you paste your 'single long text' (the complete full line) here in the forum, so we can see it's format.

Are you

  • trying to insert a newline character into a string?
  • Will this string be displayed in web (like dashboard)?

Or

  • trying to break up the function code so that is is not a long single line?

Or

  • asking how to join strings on multiple lines using + or and ?

From the way the question is described

I'm guessing;

let a = 2
let b = 3
let c = 4
let d = 5
let e = 6
// instead of let total = a + b + c + (d*a) + e
// Use assignment operators to split calculation (+= *= /= -=)
let total = a
total += b+c
total += d*a
total *= e
// 114
msg.payload = total
return msg;

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