Split string into array [duplicate]
Solution 1:
Use the .split()
method. When specifying an empty string as the separator, the split()
method will return an array with one element per character.
entry = prompt("Enter your name")
entryArray = entry.split("");
Solution 2:
ES6 :
const array = [...entry]; // entry="i am" => array=["i"," ","a","m"]
Solution 3:
use var array = entry.split("");