saileela
saileela

Reputation: 11

Remove double quotes from an array in JavaScript

var old_response = ["a,b,c","x,y,z","e,f,g"] 
new_response = ["a,b,c,x,y,z,e,f,g"]

Currently I am getting the old_response instead of that I need new_response

Upvotes: 1

Views: 683

Answers (3)

TGrif
TGrif

Reputation: 5931

You could cast your array to string:

var old_response = ["a,b,c","x,y,z","e,f,g"]
var new_response = [old_response.toString()]  // or [old_response + '']

console.log(new_response)

Upvotes: 0

Shiv Yadav
Shiv Yadav

Reputation: 161

old_response = ["a,b,c","x,y,z","e,f,g"]
console.log([old_response.join()])

Upvotes: 2

Pranav C Balan
Pranav C Balan

Reputation: 115222

Simply join the elements using Array#join method and put into a new array.

var old_response = ["a,b,c","x,y,z","e,f,g"] ;

var new_response = [old_response.join()];

console.log(new_response);

Upvotes: 2

Related Questions