It’s almost Friday! After Tommy left for work this morning, I went back to sleep. I woke up at 5 AM but only got about five and a half hours of sleep. I finally got up at 10, showered, and got ready for the day. I need to find Tommy’s glasses case, which should be around here somewhere. I haven’t eaten yet, but I did have some coffee. I’m considering having lunch soon.
I turned around in my chair to face Tommy’s desk and noticed his glasses case sitting there. It was the quickest time I’ve ever found something. The weather is expected to be warm today, with temperatures reaching up to 82 degrees. Perhaps I should open the windows since we haven’t turned on the evaporative cooler yet.
The technician who turns on the swamp cooler has arrived. However, he needs to pick up a pad for the cooler, so he will head into the city and return later. Kel went to her dad’s house and should be back soon. We need to go to the store to pick up some items for dinner. Since Tommy has band practice tonight, we’ll be on our own for the meal. Additionally, Tommy has a concert scheduled for Memorial Day morning.
Tomorrow, I’ll be hanging out at the mall with the girls. Alexis is looking for some shorts, and Kel will be dropping us off while she goes grocery shopping with Chris. Later, we might head to Target, as they might have a better selection of what Lexi is seeking.
Saturday is Karissa’s birthday. I’m not sure if we’re celebrating on Friday or Monday, but it will be one of those days. I think. She’s interested in either a power bank or skincare as gifts. I think skincare would be a practical choice; however, a power bank is also a nice option. I need a new power bank myself since mine is so old that it doesn’t even have a USB-C connection.
I spent some time working on the cloning function before heading over to FreeCodeCamp to explore some functions for fun. It was enjoyable to engage in something I understood while refreshing my memory. Now, onto the cloning function:
function deepClone(obj) { // 1. Handle null or primitive values if (obj === null || typeof obj !== 'object') { return obj; } // 2. Handle arrays if (Array.isArray(obj)) { const clonedArr = []; for (let i = 0; i < obj.length; i++) { clonedArr[i] = deepClone(obj[i]); } return clonedArr; } // 3. Handle objects const clonedObj = {}; for (let key in obj) { if (obj.hasOwnProperty(key)) { clonedObj[key] = deepClone(obj[key]); } } return clonedObj; }
Here is a breakdown of the function.
Step 1: Handle null and primitives
if (obj === null || typeof obj !== 'object') { return obj; }
Explanation:
If obj is:
- null
- a number, string, boolean, symbol, or undefined
- → These are primitive types.
Primitives don’t need cloning. You can just return them as-is because they’re already separate copies.
Step 2: Handle Arrays
if (Array.isArray(obj)) { const clonedArr = []; for (let i = 0; i < obj.length; i++) { clonedArr[i] = deepClone(obj[i]); } return clonedArr; }
Explanation:
- If obj is an array, make a new empty array.
Then go through each element in the original array:
- Clone it using deepClone() (in case the element is an object or array too).
- Put each cloned element into the new array.
Step 3: Handle Objects
const clonedObj = {}; for (let key in obj) { if (obj.hasOwnProperty(key)) { clonedObj[key] = deepClone(obj[key]); } } return clonedObj;
Explanation:
- If it’s not an array and not a primitive/null, it must be a plain object.
So:
- Make a new empty object.
- Loop over all the keys in the original object.
- For each key, clone the value inside using deepClone() and store it in the new object.





