Spaces in the array

users00024520
Tera Contributor

Hello, thanks for reading, I have the following: I have an array and I want it to have a space after the comma (,) example: Signaling, Trailer, Fuel. it´s possible? how can I do it?

find_real_file.png

1 ACCEPTED SOLUTION

Robbie
Kilo Patron
Kilo Patron

Hi Samuel,

You can easily achieve this via the .join(' ') method as shown below:

var fruits = ["Banana", "Orange", "Apple", "Mango"];
var test = fruits.join(', ');
gs.log('array: ' + test);

  

To help others, please mark correct and/or helpful.

Thanks, Robbie

View solution in original post

4 REPLIES 4

Jake Sadler
Kilo Sage

Hi,

 

Use .join(', '); //The space is in the speech marks

 

Thanks

 

Jake

Ct111
Giga Sage

Hello, Here is an example of spaces between array elements. Do chk it for reference: :

var showtimes = ["1pm", "2pm", "3pm"];

var showtimesAsString = showtimes.join(', ');

// gives "1pm, 2pm, 3pm

 

I hope this helps.

 

Mark my Answer as Correct and Helpful if ot helps

Robbie
Kilo Patron
Kilo Patron

Hi Samuel,

You can easily achieve this via the .join(' ') method as shown below:

var fruits = ["Banana", "Orange", "Apple", "Mango"];
var test = fruits.join(', ');
gs.log('array: ' + test);

  

To help others, please mark correct and/or helpful.

Thanks, Robbie

thank you! it worked!!!! 🙂