How to add double quotes to array values

Shalani Rajendr
Tera Contributor

Hi All,

I need to add double quotes to values in an array please help me on how to do that.

Example: var arr=["servicenow,community"];

I have an array like this but i need the array as var arr=["servicenow","community"]; via server script

Please tell me on how to solve this

 

1 ACCEPTED SOLUTION

Vitali1
Tera Expert

It looks like you have a value as a string but need to have multiple values instead.
You could try to split this string into multiple values before putting it in the array.
try this one

var someValue = "servicenow,community";
arr = someValue.split(',');
gs.print(arr);

View solution in original post

14 REPLIES 14

Saurabh Gupta
Kilo Patron
Kilo Patron

Hi,

Please do as below

arr=['"servicenow"','"community"'];

gs.print(arr)

find_real_file.png

If my answer replied your question please mark appropriate response as correct so that the question will appear as resolved for other users who may have a similar question in the future.

Regards,
Saurabh


Thanks and Regards,

Saurabh Gupta

Shalani Rajendr
Tera Contributor

var arr=["servicenow,community"]; i have an array like this i need to change it to var arr=["servicenow","community"];

Add single ' also before " and after ". Like below

'"servicenow"','"community"'

I need via script