make a string into array js code example
Example 1: javascript array to comma separated string
var colors = ["red", "blue", "green"];
var colorsCSV = colors.join(","); //"red,blue,green"
Example 2: string to array javascript
const str = 'Hello!';
console.log(Array.from(str)); // ["H", "e", "l", "l", "o", "!"]
Example 3: convert a string to array in javascript
// Designed by shola for shola
str = 'How are you doing today?';
console.log(str.split(" "));
//try console.log(str.split("")); with no space in the split function
//try console.log(str.split(",")); with a comma in the split function
Example 4: string to array javascript
const string = "Hello!";
console.log([...string]); // ["H", "e", "l", "l", "o", "!"]