Reputation: 11
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
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
Reputation: 161
old_response = ["a,b,c","x,y,z","e,f,g"]
console.log([old_response.join()])
Upvotes: 2
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