I have learned that people with ADHD can have sleep problems. Such as settling down for sleep (you get more energy and it feel natural to stay up late. Or from ADHD medications), restless sleep (some ADHD medications, not doing sleep enhancing behaviors before bed), and waking up in the morning (you hit a deep sleep later in the morning when it is close to the time when you wake up). And when you do wake up, you may not feel fully awake until later in the morning. Having a definite sleep schedule can help, along with doing sleep enhancing behaviors before bed, or exercise during the day can make you more tired at night. Even though I have ADHD, I have the opposite where I can fall asleep anytime, anywhere. No matter how much sleep I get. I do have restless sleep at times where I wake up a lot during the night.
Today in therapy I talked about my anxiety and having flashbacks. It would be nice to not have flashbacks. I mean, it’s been a long while. I would think that my brain would focus on the present rather than bringing up the past. Why show me images of the knife thrown at me, trigger me when I hear loud noises? Why can’t my brain stop dissociating and just be ok? It’s been a long while since I have been around anyone from my past. My brain should be happier and more content. That’s what I want for my brain. To be content.
I owe six dollars to the people who provide my cpap mask. I should pay that, but maybe call them and see if my insurance will take over the payment.
I shall get back to coding. Today we are adding properties to objects and accessing property names with bracket notation. It’s easy if I can remember the syntax. I wish they gave more problems for each topic so I have a better learning experience.
JavaScript notes…
————————————————————
At their most basic, objects are just collections of key-value pairs. In other words, they are pieces of data (values) mapped to unique identifiers called properties (keys). Take a look at an example:
const tekkenCharacter = { player: 'Hwoarang', fightingStyle: 'Tae Kwon Doe', human: true };
The above code defines a Tekken video game character object called tekkenCharacter. It has three properties, each of which map to a specific value. If you want to add an additional property, such as “origin”, it can be done by assigning origin to the object:
tekkenCharacter.origin = 'South Korea';
This uses dot notation. If you were to observe the tekkenCharacter object, it will now include the origin property. Hwoarang also had distinct orange hair. You can add this property with bracket notation by doing:
tekkenCharacter['hair color'] = 'dyed orange';
Bracket notation is required if your property has a space in it or if you want to use a variable to name the property. In the above case, the property is enclosed in quotes to denote it as a string and will be added exactly as shown. Without quotes, it will be evaluated as a variable and the name of the property will be whatever value the variable is. Here’s an example with a variable:
const eyes = 'eye color'; tekkenCharacter[eyes] = 'brown';
After adding all the examples, the object will look like this:
{ player: 'Hwoarang', fightingStyle: 'Tae Kwon Doe', human: true, origin: 'South Korea', 'hair color': 'dyed orange', 'eye color': 'brown' };
Now let’s take a look at a slightly more complex object. Object properties can be nested to an arbitrary depth, and their values can be any type of data supported by JavaScript, including arrays and even other objects. Consider the following:
let nestedObject = { id: 28802695164, date: 'December 31, 2016', data: { totalUsers: 99, online: 80, onlineStatus: { active: 67, away: 13, busy: 8 } } };
nestedObject has three properties: id (value is a number), date (value is a string), and data (value is an object with its nested structure). While structures can quickly become complex, we can still use the same notations to access the information we need. To assign the value 10 to the busy property of the nested onlineStatus object, we use dot notation to reference the property:
nestedObject.data.onlineStatus.busy = 10;
In the first object challenge we mentioned the use of bracket notation as a way to access property values using the evaluation of a variable. For instance, imagine that our foods object is being used in a program for a supermarket cash register. We have some function that sets the selectedFood and we want to check our foods object for the presence of that food. This might look like:
let selectedFood = getCurrentFood(scannedItem); let inventory = foods[selectedFood];
This code will evaluate the value stored in the selectedFood variable and return the value of that key in the foods object, or undefined if it is not present. Bracket notation is very useful because sometimes object properties are not known before runtime or we need to access them in a more dynamic way.