To add spaces between array items in JavaScript, we use the join
method.
For instance, we write
const showtimes = ["1pm", "2pm", "3pm"];
const showtimesAsString = showtimes.join(", ");
to call showtimes.join
with ', '
as the delimiter between each string in showtimes
.
Therefore, showtimesAsString
is "1pm, 2pm, 3pm"
.