Convert array to string

function-node
#1

Hi Folks,

What is the easiest way to convert an array on a payload into a string of the array values with a separating character between each value?

Thanks

Paul

#2

I would recommend a Function Node with something similar to this:

myArray = payload.data.myArray; // ['red', 'blue', 'green']
payload.data.myString = myArray.join(','); // "red,blue,green"

Check out MDN for more details on the Array.join function.

I could see adding this as a potential feature to our existing Array Node.

2 Likes