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 Answers 2
var array = [100, 200, 300];
var str = array.join(',');
console.log(str);
answered Aug 23, 2017 at 15:18
kyun
10.4k9 gold badges36 silver badges79 bronze badges
Sign up to request clarification or add additional context in comments.
Comments
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
James Gould
4,7583 gold badges31 silver badges57 bronze badges
1 Comment
Giri Sreerangam
array.join("'',''")
lang-js
"100", "200", "300"or a string like:100,200,300?