+ 2

How to make a string an array and vice versa

How would you make a string an array and vice versa in Javascript?

10th Apr 2018, 11:26 AM
Leroy Jenkins
Leroy Jenkins - avatar
2 Réponses
+ 3
For string to array: Use stringVar.split(delimiter) The delimiter is what you’re splitting the string by. For an array of every character, do this: stringVar.split(“”);
10th Apr 2018, 11:31 AM
Ariela
Ariela - avatar
+ 3
To make an array into a string, use arrayVar.join()
10th Apr 2018, 11:32 AM
Ariela
Ariela - avatar