Reputation: 2229
I have the method below in my react.js application. I will like to concatenate this line {dt.productCode} {dt.sizeCode} {dt.itemWearerName} such that asterisk will be between them.
1234*xl*tester
How can I achieve that?
renderInvoicesProducts(){
return this.state.invoicesProducts.map((dt, i) => {
return (
<MenuItem key={i} value={dt.customerInvoiceProductId}>
{dt.productCode} {dt.sizeCode} {dt.itemWearerName}
</MenuItem>
);
});
}
Upvotes: 0
Views: 39
Reputation: 17259
If you have some number of things and you want to add something between them, then .join()
can be a good approach.
const things = ['one', 'two', 'three'];
const s = things.join('*')
console.log(s) // one*two*three
You can read more about .join
here.
Upvotes: 0
Reputation: 51
When I want space between values like that, I use {' '}. [Note the spacing given in between the quotes] Try to add asterisk in similar way and check.
Upvotes: 0
Reputation: 589
You cant just put an asterisk between them as such?
renderInvoicesProducts(){
return this.state.invoicesProducts.map((dt, i) => {
return (
<MenuItem key={i} value={dt.customerInvoiceProductId}>
{dt.productCode}*{dt.sizeCode}*{dt.itemWearerName}
</MenuItem>
);
});
}
Upvotes: 1