if I have a list:
Fruit apple text = a red fruit pear text = a green fruit
What’s an effective way to join the ‘text’ properties to create something like “a red fruit, a green fruit”.
Does this require a custom function or can the perchance list methods handle this?
thanks
You must log in or # to comment.
You can use JavaScript array methods for that.
Fruit apple text = a red fruit pear text = a green fruit output [Fruit.selectAll.map(fruit => fruit.text).join(", ")]Fruit.selectAllwill create an array of all the items in theFruitlist, you can also use.selectMany(...)or.selectUnique(...)to create an array of items..map(fruit => fruit.text)will essentially transform the array to have thetextproperty of thefruitas the elements, instead of thefruitthemselves..join(", ")would join the items into a single string with,as the delimiter
That works perfectly. Thanks so much for the explanation.


