how to cut a string sentence into two halves using split method.
Hello Satheesh,
You can cut a string into two halves either using substring
or slice
methods as shown below:-
const allAlphabetsInEnglish = `the quick brown fox jumps over the lazy dog`;
const firstHalf = allAlphabetsInEnglish.substring(0,21);
const secondHalf = allAlphabetsInEnglish.slice(21,43);
console.log(`First half is : ${firstHalf}`);
console.log(`Second half is : ${secondHalf}`);