I have,
{
mydata.map(({
name
}) => ( <p style = {{
display: "inline" }} > { " " } { name }, </p>))
}
How can I remove the last comma in banana, apple, orange,
the result of the code, that is, the one after orange
and make it look something like this: banana, apple, orange
?
Thank you very much!
{mydata.map(({name}, idex) => (
<p style={{display:"inline"}}>
{" "}{name} {index === mydata.length - 1 ? "" : ","}
</p>
))}
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