Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Working with array in javascript [closed]

I have an array

var arr = ["one","two","three","four"];

Is it possible to convert it like this through some regexes

"one","two","three","four"

the resultant should not be an entire string rather it is comma separated strings.

Any suggestions ???

like image 758
selvagsz Avatar asked Sep 21 '26 13:09

selvagsz


1 Answers

function func(){
   var arr = ["one","two","three","four"];
   var result = "";
   for (var i = 0; i <= arr.length - 1; i++) {
       result += '"' + arr[i] + '",';
   }
   result = result.substring(0, result.length - 1);
   alert(result);
}

like image 126
prageeth Avatar answered Sep 24 '26 03:09

prageeth



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!