Convert array to string without comma in javascript

While working with javascript arrays, there is often a requirement to convert an array to a string without commas. This article demonstrates how to convert an array to a string without commas as separators in javascript.

Convert array to string without comma using join()

Javascript’s join(separator) method will join all the elements of an array into a single string divided by the separator passed in the method’s argument.

Example1:-

Convert the array [“Javascript”, “Is”, “Popular”,”Language”] to string without commas

Code:-

let stringArray = ["Javascript", "Is", "Popular","Language"];
let finalString  = stringArray.join("");
console.log(finalString);

Output:-

JavascriptIsPopularLanguage

Explanation:-

  • The join() method is used.
  • Blank value(“”) is passed in as an argument while converting the array to a string value.
  • This string value is stored in finalString and printed on the console.

Example2:-

Convert the array [“Javascript”, “Is”, “Popular”,”Language”] to string without commas separated by dash.

Code:-

let stringArray = ["Javascript", "Is", "Popular","Language"];
let finalString  = stringArray.join("-");
console.log(finalString);

Output:-

Javascript-Is-Popular-Language

Explanation:-

  • The join() method is used.
  • Dash(“-“) is passed in as an argument that becomes a separator while converting the array to a string value.
  • This string value is stored in finalString and printed on the console.

Read More:

I hope this article helped you with conversions of the array to a string without commas in javascript. Good Luck !!!

1 thought on “Convert array to string without comma in javascript”

Leave a Reply to Anjal Cancel Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Scroll to Top