JavaScript split method

let sentence = "_We want to count the number of words in this sentence";

//1. Case with single character

console.log(sentence.split(' '));
//Result:
//(11)['_We', 'want', 'to', 'count', 'the', 'number', 'of', 'words', 'in', 'this', 'sentence']

//2. Case with a string
console.log(sentence.split('to'));
//Result: 
//(2)['_We want ', ' count the number of words in this sentence']

//3. Case without spearator
console.log(sentence.split());
//Result: 
//['_We want to count the number of words in this sentence']

//4. Case on the beggining or the end
console.log(sentence.split('_'));
//Result:
//(2)['', 'We want to count the number of words in this sentence']

//5. Empty string separator
console.log(sentence.split(''));
//Result: 
//(54)['_', 'W', 'e', ' ', 'w', 'a', 'n', 't', ' ', 't', 'o', ' ', ...]