var Str = "Hello There!"
var SplitOn = " "
var Results = Str.split(SplitOn);
//Results[0] will be 'Hello' and Results[1] will be 'There!'
yourStr.split('')
let string = "How are you?";
const newArr = string.split(" ");
var myString = "Hello World!";
// splitWords is an array
// [Hello,World!]
var splitWords = myString.split(" ");
// e.g. you can use it as an index or remove a specific word:
var hello = splitWords[splitWords.indexOf("Hello")];
const splitText = (string) => {
const newText = string
.split(/((?:w+ ){1})/g)
.filter(Boolean)
.join("
");
return newText
};
console.log(splitText("Hello, world"));
//Hello,
//world
const string = "this is the array that we want to split";
var splittedString = string.split(" ") //place the separator as a parameter
/* splittedString:
* ['this', 'is', 'the', 'array', 'that', 'we', 'want', 'to', 'split']
*/
//The split() method takes a pattern and divides a String into an ordered list of substrings by searching for the pattern, puts these substrings into an array, and returns the array.
const str1 = 'The quick brown fox jumps over the lazy dog.';
const words = str1.split(' ');
console.log(words[3]);
// expected output: "fox"
const chars = str1.split('');
console.log(chars[8]);
// expected output: "k"
const strCopy = str1.split();
console.log(strCopy);
// expected output: Array ["The quick brown fox jumps over the lazy dog."]
var myArray = myString.split(",");
var myArray = myString.split(" ");