Reputation: 5520
I have an array that I want to translate into a string
100
110
120
145
I want this result/output:
"100","110","120","145"
I tried:
var send_data_ids = $.map( ids_above, function( n ) {
return String.fromCharCode(34) + n + String.fromCharCode(34);
});
But then I get double quotations. Why?
""100"",""110"",""120"",""145""
Upvotes: 0
Views: 655
Reputation: 36703
$.map
will return another array, if you want a string just use:
var x = ["100","110","120","145"];
var y = "\""+x.join("\",\"")+"\"";
or in your code do
var send_data_ids = $.map( ids_above, function( n ) {
return String.fromCharCode(34) + n + String.fromCharCode(34);
});
var y = "\""+send_data_ids.join(",")+"\"";
Upvotes: 1