Dark Mode
Enable Console
stringToArray(string)
/*
Converts a string into an array of words
*/
stringToArray("Hello there");
// ["Hello", "there"]
stringToArray("Convert this into an array");
// ["Convert", "this", "into", "an", "array"]
Solution by - Need4Swede
function stringToArray(string){
// Split the string into an array, seperated by whitespaces and return the outcome
return string.split(" ");
}
Try it yourself - Codewars Source