0

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?

1
  • 3
    var string = "123", "456", "789" is just var string = "789" Commented Jun 21, 2017 at 7:38

1 Answer 1

5

You could stringify the elements before joining.

var array = ["123", "456", "789"],
    result = array.map(a => JSON.stringify(a)).join();
    
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.