I completed the Palindrome Checker project. The code seems straightforward, but creating it from scratch took me the longest time. When it comes to coding, Google is your best friend. Interestingly, setting up the HTML page took longer than I had anticipated. I had to seek assistance to remember to set up the HTML page. Although I know how to link the HTML page to the JavaScript page, setting up HTML, which I last used a while ago, proved more complex than it had any right to be. However, the basic HTML template is simple; I must remember how to set it up.
It has been quiet here at the house today. I read more of Fourth Wing last night. I’m getting some Hunger Games vibes while reading. Of course, I’ve only read the first book of Hunger Games. The world-building is detailed and well thought out. The author has effectively conveyed how small and vulnerable the protagonist is. I feel this won’t be the last time I hear about her vulnerability. So far, I’m enjoying the book.
JavaScript notes…
——————————
FreeCodeCamp Build a Palindrome Checker
** start of HTML **Document ** end of HTML ** ** start of JavaScript ** const textInput = document.getElementById("text-input"); const checkButton = document.getElementById("check-btn"); const result = document.getElementById("result"); checkButton.addEventListener("click", () => { const lowerReplaced = textInput.value.toLowerCase().replace(/[^a-z0-9]/g, "") if (textInput.value === "") { alert("Please input a value"); } else if (textInput.value.length === 1) { result.innerText = `${textInput.value} is a palindrome`; } else if (lowerReplaced === [...lowerReplaced].reverse().join("")) { result.innerText = `${textInput.value} is a palindrome`; } else { result.innerText = `${textInput.value} is not a palindrome`; } }); ** end of JavaScript **