-3

I need to convert list of strings

const ar: string[] = ['str1', 'str2']

to a string which contains ar container with square brackets [] and quotes "

const str: string = `["str1", "str2"]`

how to do it in proper way?

1
  • 5
    JSON.stringify(ar) Commented Dec 26, 2018 at 16:50

1 Answer 1

1

The format you want is a JSON array string. So use the JSON object's stringify function. JSON.stringify(["some", "array", 123]);

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.