Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

convert a string to an array javascript

function stringToArray(string){
const arr = string.split(" ");// add space in between qoutes to avoid splits every letters in string
  return arr
}
//splitting 
const str = stringToArray('hello world!');
console.log(str); //output: [ 'hello', 'world!' ] 
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #convert #string #array #javascript
ADD COMMENT
Topic
Name
1+2 =