I’ve just had my second cup of coffee. I’m trying to figure out how to write a function that checks if a word is a palindrome. This is what I have so far:
function isPalindrome(str) { // Convert string to lowercase and remove non-alphanumeric characters let cleanStr = str.toLowerCase().replace(/[^a-z0-9]/g, ""); }
In the context of Regedit (Windows Registry Editor), the regular expression /[^a-z0-9]/g, “” means: “Find and replace any character that is not a lowercase letter (a-z) or a number (0-9) with an empty string (essentially deleting those characters)” across the entire searched text due to the “g” (global) flag. Now I need to reverse the cleaned string. Probably needs to split and join the string also. Then lastly, to check if the cleaned string matches the reversed string. So I need to put that into code.
function isPalindrome(str) { // Convert string to lowercase and remove non-alphanumeric characters let cleanStr = str.toLowerCase().replace(/[^a-z0-9]/g, ""); // Reverse the cleaned string let reversedStr = cleanStr.split("").reverse().join(""); // Check if the original cleaned string matches the reversed one return cleanStr === reversedStr; }
The most challenging aspect of this code is the regular expression that eliminates any character that isn’t a lowercase letter or a number. Once I understood what needed to be done, the rest fell into place fairly easily. I found some pseudocode that clarified the requirements, and from there, it was just a matter of coding.
During lunch, I watched an episode of Tasting History that focused on Girl Scout cookies. I learned that in the early days, the Girl Scouts baked their own cookies and sold them themselves. Each Girl Scout followed a single recipe and was encouraged to sell the cookies to neighbors or at schools, but not “on the streets.” Interestingly, during World War II, the Girl Scouts sold calendars instead of cookies. It wasn’t until 1936 that they began selling commercially baked cookies, which allowed for broader availability.
Back to coding. I now need to write a function that returns an array containing the first ‘n’ Fibonacci numbers. The Fibonacci sequence starts with [0, 1], and each next number is the sum of the previous two. This one seems more confusing than the palindrome function. Google has shown so many examples that it’s a bit overwhelming.
I took a break when Kel arrived home to collect the mail. We needed to stop by the post office since one of the packages was sent there instead of our mailbox. There’s a stack of mail piling up on my desk that I need to sort through to determine what should be shredded and what can be thrown away. Additionally, I have some clothes that need to be put away later.
It’s after 5 now. I’m going to put away clothes and make Tommy’s lunch for tomorrow.





