| Mods 4 Assignnment |

Text Strings & String Methods

The Main String: "I hope you have a great Day!"

Demonstrations:

1. This will give you the length of the "main string".

document.getElementById("string1").textContent = `Length: ${mainString.length}`;




2. This will change the "main string" to all uppercase letters.

document.getElementById("string2").textContent = `Uppercase: ${mainString.toUpperCase()}`;




3. This will change the "main string" to all lowercase letters.

document.getElementById("string3").textContent = `Lowercase: ${mainString.toLowerCase()}`;




4. This will gather all the characters in the substring of the "main string" from 0, 23.

document.getElementById("string4").textContent = `Substring(0, 23): ${mainString.substring(0, 23)}`;




5. This will replace a word in the substring of the "main string" to another word.

document.getElementById("string5").textContent = `Replace "great" with "Wonderful": ${mainString.replace("great", "wonderful")}`;




6. This will get you the character thats placed in the 7th spot of the "main string".

document.getElementById("string6").textContent = `Character at index 7: ${mainString.charAt(7)}`;




7. This will give you the placement or index of the word hope in the "main string".

document.getElementById("string7").textContent = `Index of "hope": ${mainString.indexOf("hope")}`;




8. This will give you the length of the charcaters in the "main string" from 0 to the !.

document.getElementById("string8").textContent = `Last index of "!": ${mainString.lastIndexOf("!")}`;