function reverseString() {
// First, get the user's input and validate it to be 2 or more characters.
let userWord = document.getElementById("tacoCat").value;
if (userWord.length < 2) {
alert("Please try something with 2 or more characters.")
return;
}
// Now begin the reversal by stripping the string of all special characters
// and storing it in a new variable cleanedWord
let cleanedWord = userWord.replace(/[^A-Z0-9]/ig, "");
let cleanUp = document.getElementById("cleanItUp")
cleanUp.innerText = cleanedWord;
// Create a variable for storing the reversed string, then iterate
// through the cleanedWord and put the result in it
let reversedWord = "";
let start = cleanedWord.length - 1;
for (let i = start; i >= 0; i--) {
reversedWord += cleanedWord[i];
}
// Send the reversed string to the document for display
let output = document.getElementById("tacoOutput");
output.innerText = reversedWord;
// Perform a comparison to check for identicality. If identical, winner-winner-chicken-dinner!
if (reversedWord == cleanedWord) {
let palOut = document.getElementById("isItPal");
palOut.innerText = "Yes, that is proper palindromification!"
} else {
let palOut = document.getElementById("isItPal");
palOut.innerText = "Not this time. Keep trying, pal..."
}
}