Split string into array [duplicate] Split string into array [duplicate] arrays arrays

Split string into array [duplicate]


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("");


ES6 :

const array = [...entry]; // entry="i am" => array=["i"," ","a","m"]