-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?

Yuriy Gyerts
  • 1,464
  • 18
  • 30

1 Answers1

1

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

tpayne84
  • 181
  • 1
  • 9