Today is Alexis’s birthday! I’ve shared her birth story here. She turns 22 today, and I hope she has a wonderful day; I miss her since she is away at school.
I document my daily activities in my planner, which serves as a sort of mini journal. This practice is helpful, as I often refer back to it when writing in my main journal. The weather is beginning to warm up, with temperatures reaching 70 degrees today. Perhaps we can start working on my desk soon, as it needs warmth for staining. I’m glad to see the temperatures rising. It must be quite hot in the city today. The city has a much lower elevation. One of the benefits of living at a higher elevation is that it rarely gets excessively hot here; we might experience a few days of heat, but then the temperatures usually cool down again. Although, we experience more extreme weather changes than in the city.
On Friday, Tommy had two back-to-back dentist appointments. Karissa and I waited in the lobby while he was seen by the dentist. Karissa joined us because she needed to pick up her new glasses. After Tommy’s appointments, we went to the music store to get his saxophone fixed. Following that, we headed to Costco to collect Karissa’s glasses. Tommy then had his therapy session, which he completed in the car while Karissa and I strolled around Costco and enjoyed a smoothie from the food court. Once Tommy was finished, we picked up some items for dinner and headed home.
On Saturday, Tommy and I lifted weights together as we worked to re-establish our workout routine. My legs and arms are still sore from weightlifting. Around 1 PM, Tommy headed to band practice, where they were preparing for their upcoming concert on Sunday.
On Sunday morning, we worked out together. Tommy had his concert at 3 PM, which was fantastic. The band performed brilliantly, and Tommy’s saxophone playing has significantly improved since he resumed. After the concert, we decided to head to Dion’s for dinner since the band was going there. I ordered two slices of pizza but could only manage to eat one, so I saved the second for lunch today.
As we were leaving Dion’s, we noticed a car on its side. It appeared the accident had just occurred, as the emergency workers hadn’t arrived yet. I sincerely hope everyone involved is okay.
Chris wasn’t feeling well, so we stopped by Walmart to pick up a few essentials for him and delivered them to his dorm. Later, we visited Smith’s to gather ingredients for tonight’s dinner, which will consist of lamb accompanied by potatoes, carrots, celery, and onion. Kel found a recipe online, and I prepared the meal in the slow cooker earlier this morning.
Today in coding, I need to write a function that takes a nested array and returns a flattened version of it. I’m unsure if I’ve already completed this task or not. It’s also worth noting that there is a `flat()` method available. The `flat()` method of Array instances creates a new array by recursively concatenating all elements of the sub-arrays up to a specified depth. I’m still contemplating whether to incorporate this method within my function. Since I’m not quite sure if it is needed to include that method. The skeleton code is as follows:
function flattenArray(arr) { // Code here }
I’ve done a bit more reading on the topic. Flattening a nested array involves converting an array that contains sub-arrays into a single array consisting of all its elements. It doesn’t seem too difficult, at least I hope not! If you know the level of nesting, you can use `.flat(depth)`, or simply use `Infinity` to flatten it completely. So, wouldn’t that mean you can just return `.flat(Infinity)`?
function flattenArray(arr) { return arr.flat(Infinity); }
And the console.log works!
console.log(flattenArray([1, [2, [3, 4], 5], 6])); // Output: [1, 2, 3, 4, 5, 6]
Let’s do another function. I need to write a function that capitalizes each word. Ok, I know we need to use .toUpperCase() and split(), map() and join().
function capitalizeWords(str) { return str.split(' ') // Split the string into an array of words .map(word => word.charAt(0).toUpperCase() + word.slice(1)) // Capitalize each word .join(' '); // Join the words back into a string }
.map(word => word.charAt(0).toUpperCase() + word.slice(1)) → Capitalizes the first letter of each word and keeps the rest unchanged.
- .map() is an array method that creates a new array by applying a function to each element in the original array.
- In this case, the original array is the array of words we got from .split(‘ ‘).
word.charAt(0)
- Extracts the first character of the word.
- Example: “hello”.charAt(0) → ‘h’
.toUpperCase()
- Converts the first character to uppercase.
- Example: ‘h’.toUpperCase() → ‘H’
word.slice(1)
- Extracts the rest of the string starting from index 1 (excluding the first character).
- Example: “hello”.slice(1) → “ello”
Concatenation (+)
- Combines the uppercase first letter with the rest of the word.
- Example: ‘H’ + ‘ello’ → “Hello”
Well, I need to look through this medical renewal form. So I will post this now and maybe get some hot tea.





