I tried to map and join from the object below.
production_countries:
0:
iso_3166_1: "GB"
name: "United Kingdom"
1:
iso_3166_1: "US"
name: "United States of America"
I tried production_countries?.map((name) => (name.join(','))) and it doesn't render.
I want the result to be United Kingdom, United States of America
I didn't try it but I think this will work.
production_countries?.map((item) => item.name).join(', ');
Because map will return array of only names then we join all elements of that array.
With above code you may end up having a space at the end of the string. You may call trim() string method to get rid of that.
production_countries?.map((item) => item.name).join(', ').trim();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With