2

I wanted to know if there was a function that could turn an array into a string separated with Quotation Marks and commas in JS?

var array = [1,2,3]

var result = '["1", "2", "3"]';

1 Answer 1

6

You can use .map to convert array elements to strings, and JSON.stringify to get the resulting string:

const array = [1,2,3];

const result = JSON.stringify(array.map(String));

console.log(result);

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.