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

asked Aug 23, 2017 at 15:15
2

2 Answers 2

2
var array = [100, 200, 300];
var str = array.join(',');
console.log(str);
answered Aug 23, 2017 at 15:18
Sign up to request clarification or add additional context in comments.

Comments

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('","');

answered Aug 23, 2017 at 15:17

1 Comment

array.join("'',''")

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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.