I have array like this
var array =["123", "456", "789"]
How do I convert this into var string = "123", "456", "789"
I tried join and other things so far I was unable to produce my desired result.
Any idea how it can be achieved?
asked Jun 21, 2017 at 7:36
Januka samaranyake
2,6072 gold badges34 silver badges54 bronze badges
1 Answer 1
You could stringify the elements before joining.
var array = ["123", "456", "789"],
result = array.map(a => JSON.stringify(a)).join();
console.log(result);
answered Jun 21, 2017 at 7:38
Nina Scholz
388k26 gold badges367 silver badges417 bronze badges
Sign up to request clarification or add additional context in comments.
Comments
lang-js
var string = "123", "456", "789"is justvar string = "789"