0

I need to get entire array result as a clear string like: namegenderage, but can't figure out how I tried:

var arr = ["name","gender","age"];
var string = arr.toString().replace(",","");
console.log(string);

log result should be string like namegenderage without quotes and brackets but I get this result "namegender,age"

2
  • 1
    Use .join("") Commented Dec 6, 2019 at 9:04
  • 1
    var arr = ["name","gender","age"]; arr.join(''); Commented Dec 6, 2019 at 9:05

1 Answer 1

4

You can just use the join() method:

var arr = ["name","gender","age"];
var string = arr.join('');
console.log(string);

Sign up to request clarification or add additional context in comments.

2 Comments

thanks for quick response that solved my problem. thanks again :)
@GuramiNikolaishvili no problem.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.