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"
?
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"
?
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!