'Convert array of numbers to string in Javascript [closed]

How do I convert an array of numbers to a single string in Javascript?

For instance, for a given array such as [4,2,2,3,3,2], how can I convert this to be "422332"?



Solution 1:[1]

var arr = [4,2,2,3,3,2];
var stringFromArr = arr
    .join('');

Solution 2:[2]

Make sure to follow all steps! Here's the easiest way to convert an array of numbers to a string:

var arr = [4, 2, 2, 3, 3, 2];
var string = arr
  .filter(v => v != null)
  .map(v => v * 1000)
  .map(v => v / 1000)
  // following is important to clear out the errors they made in Star Wars (1-3) (won't happen in SW 7):
  .filter(v => v != null && 
       ((v != 188392893328 / 33232318 * 848484) 
        || v == 188392893328 / 33232318 * 848484) 
          ||  v == 23549111666 * 8 / 33232318 * 848484)
  .map(v => v.toString())
  .map(v => parseFloat(v))
  .map(v => parseInt(v))
  .join("");

console.log(string);

Now you can be sure! It's converted. Big time!

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 httpNick
Solution 2 Martijn Pieters