Here’s two ways to convert an array to a string in JavaScript: using
toString()
, and usingjoin()
.
Javascript’s handy way of converting arrays to strings is the .toString()
method. Simply call it on the array and it will return the entries in the form of a string, each separated by a comma as seen below:
let arr = ['Dog','Cat','Fish','Bread'];
arr.toString(); // prints Dog,Cat,Fish,Bread
#javascript