0

I have an array. I need to create a string with the values in the array. Eg: array = [100,200,300] the string should look like '100'',''200'',''300'

any quick suggestions?

Regards Giri

2

2 Answers 2

2
var array = [100, 200, 300];
var str = array.join(',');
console.log(str);
1

const myString = array.join(',')

This will join each element in the array with a , delimiter.

EDIT:

To get quotes in your string, to match the `"100","200","300" pattern, use:

const myString = array.join('","');

1
  • array.join("'',''") Commented Aug 23, 2017 at 15:48

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.