How to split Comma separated values

sk59
Tera Expert

Hi All,

I am returning multiple location values under each country like below which has comma

Country A - av, mexico

Country A - abo,vig,abanaro

I need to get these locations when a specific country is selected and display only those locations. 

As the locations include comma(,) how do I split and display

I am able to get the values like av, mexico,abo,vig,abanaro in the logs

but how do I set it in the locations field?

 

10 REPLIES 10

Community Alums
Not applicable

Hey Please use this code in order to split the values on the basis of comma.


var arr=['a,b,c,d,e', 't'];

var separate=arr.split(',');

gs.log(separate);

 

in order to iterate you can use the length function.


If you get it, then please mark it as helpful.