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
2 Comments
VioneT@lemmy.world · 3 pts · 1y
You can use JavaScript array methods for that.
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 delimiterdanMiller@lemmy.world · 1 pts · 1y
That works perfectly. Thanks so much for the explanation.