Answers for "sstring to array"

1

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
Posted by: Guest on January-17-2021
0

convert a string to array

b="1,2,3,4".split(',').map(x=>+x)

// Output : [1,2,3,4]
Posted by: Guest on October-23-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language