0

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>
                    );
                });
            }

3 Answers 3

1

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>
                );
            });
        }
Sign up to request clarification or add additional context in comments.

Comments

0

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.

Comments

0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.