I didn’t write yesterday because I was away from home all day and didn’t have the opportunity. Well, I had the opportunity before bed but I was pretty tired. I returned around 8:30 PM and prepared Tommy’s lunch for today. Kel, Alex, and I accompanied Tommy when he left for work so we could use the car. We dropped him off and then went to the location where Alex was having his job interview, waiting until it began.
I’m happy to share that Alex got the job! He is really excited about it and will be working in security. After his interview, we all went to a friend’s house. Alex spent some time with us before heading off to hang out with the kids. Meanwhile, Kel, our friend, and I continued planning our upcoming trip later this year. While planning is enjoyable, it can also be quite stressful.
I had lunch and then headed into their office for my therapy session. It went well; we discussed my childhood and its connection to my present experiences—particularly how I perceive and react to situations. It was quite insightful. We explored the reasons behind my difficulty in connecting with others. We also engaged in some Internal Family Systems (IFS) work, which helped me feel better about myself and provided clarity on my behaviors.
For some reason, I’m currently experiencing a bit of memory trouble and can’t recall everything that was discussed during the session. I’m certain I didn’t dissociate, so I’m unsure why I’m having this difficulty.
After therapy, I participated in more planning for our trip. Tommy finished work at 4:30 and got a ride back to our friend’s house. The weather was quite challenging yesterday, with strong winds and dust; we received several severe dust storm warnings on our phones. The view of the city from their window was completely obscured by the dust. We continued planning our trip until dinner time, during which we had sub sandwiches. I didn’t finish all of mine, so that will be my lunch today.
The house is particularly quiet today. Sandy is sprawled out on my lap, and she will likely get up soon to take her afternoon nap, as she usually does around lunchtime.
In terms of coding, I need to create a function that groups an array of objects based on a specified property. I’m currently researching this, as it’s a bit confusing for me. I understand that I need to take an array of objects as input and accept a property name to group by. The approach involves using .reduce() to iterate through the array and organize the objects into groups. Here’s the basic structure of the code:
function groupBy(arr, key) { // Code here }
The console.log looks like this:
const people = [ { name: "Alice", age: 25 }, { name: "Bob", age: 30 }, { name: "Charlie", age: 25 } ]; console.log(groupBy(people, "age")); // { // 25: [{ name: "Alice", age: 25 }, { name: "Charlie", age: 25 }], // 30: [{ name: "Bob", age: 30 }] // }
This code here works with the console.log:
function groupBy(array, property) { return array.reduce((acc, obj) => { // Get the value of the given property const key = obj[property]; // If the key doesn’t exist in the accumulator, initialize it as an empty array if (!acc[key]) { acc[key] = []; } // Push the current object into the corresponding group acc[key].push(obj); return acc; }, {}); // Initial accumulator is an empty object }
- .reduce() iterates over the array once, building up acc step by step.
- The initial value is {} (an empty object).
- Each object is categorized under a property (e.g., age).
- If a category doesn’t exist yet, it is initialized as an empty array.
- The object is then pushed into its respective group.
My next task is to implement my own version of the `Array.prototype.map` method. First, I need to understand what the `Array.prototype.map` method actually does. This method in JavaScript is designed to create a new array by applying a specified function to each element of an existing array. It doesn’t alter the original array; instead, it returns a new array containing the transformed values. The syntax is:
const newArray = originalArray.map(callbackFunction);
- callbackFunction(element, index, array) is a function that runs for each element in the array.
- element → The current element being processed.
- index (optional) → The index of the current element.
- array (optional) → The original array.
The skeleton code and console.log are:
function customMap(arr, callback) { // Code here } console.log(customMap([1, 2, 3], x => x * 2)); // [2, 4, 6]
I’m going to keep researching this and make myself some matcha tea. Oh, Karissa’s glasses are ready at Costco. Maybe tomorrow we can go down there.





