Working with text
Strings come with many useful methods. A few you will use constantly:
const s = "Hello, Harare";
s.length; // 13
s.toUpperCase(); // "HELLO, HARARE"
s.toLowerCase(); // "hello, harare"
s.includes("Harare"); // true
s.indexOf("H"); // 0 (position of the first match)
s[7]; // "H" (one character, counting from 0)
s.slice(7); // "Harare" from position 7 to the end
s.slice(0, 5); // "Hello" from 0 up to (not including) 5
s.trim(); // removes spaces at both ends
split and join
split cuts a string into an array; join glues an array back into a string:
"red,green,blue".split(","); // ["red", "green", "blue"]
["a", "b", "c"].join("-"); // "a-b-c"
"hello".split(""); // ["h", "e", "l", "l", "o"]
Strings never change in place: every method returns a new string.
Your task
Write three functions:
initials(fullName):"Tariro Moyo"gives"T.M."(always upper case).isPalindrome(word):trueif the word reads the same backwards, ignoring upper and lower case.countWord(text, word): how many words intextequalword, ignoring case. Words are separated by single spaces.