Happy Monday! I’m listening to coding music. Yes, that is a thing. There is so much to remember when it comes to JavaScript. I have more notes.
Tomorrow is the anniversary of Kevin’s death. I can’t believe it has been 19 years. I remember the day well. The week leading up to his funeral is still a blur, though I can remember snippets. I remember the girls getting baptized. And Mike and I in front of the coroner’s office. We never went inside. My dad did a good job of talking Mike out of going in to see if we could see Kevin. I was told that he would not be recognizable. The girls are both over 18, so if they want to see their dad’s police report and other things they can. But they have never asked. I think that is best. I don’t remember much of the funeral. I remember Mike putting Kevin’s box of ashes into this; I don’t know what it is called. It was a marble box with many slots for urns. They closed it up. I don’t remember more than that of the funeral. I remember Kevin’s aunt telling my dad that I should take my dad’s car and I can buy him a new car with the money I was getting. I don’t understand that. I’m still confused about why she thought that was a good idea. My dad didn’t go for that. I remember the day after the drunk driver killed him. Laying in my bed feeling alone but having to live on and go about my day and take care of my girls. I went to our apartment that day to move out to my parent’s house. We had no furniture except beds, a table, and fold-up chairs. So moving wasn’t hard. This paragraph is so jumbled cause my mind is still blurred by the events that happened.
I wonder if he is happy about where I am right now? I’m sure he is proud of the girls.
Easter was good. It was relaxing. We had Chile Relleno casserole and beans. And then some mini pies. It was good.
My post is a bit all over the place today. I apologize for that.
Here are my JavaScript notes. It was all about Strings today. Some of it was easy and others were a little confusing.
————————————————–
String values in JavaScript may be written with single or double quotes, as long as you start and end with the same type of quote. Unlike some other programming languages, single and double quotes work the same in JavaScript.
const doubleQuoteStr = "This is a string"; const singleQuoteStr = 'This is also a string';
The reason why you might want to use one type of quote over the other is if you want to use both in a string. This might happen if you want to save a conversation in a string and have the conversation in quotes. Another use for it would be saving an < a > tag with various attributes in quotes, all within a string.
const conversation = 'Finn exclaims to Jake, "Algebraic!"';
However, this becomes a problem if you need to use the outermost quotes within it. Remember, a string has the same kind of quote at the beginning and end. But if you have that same quote somewhere in the middle, the string will stop early and throw an error.
const goodStr = 'Jake asks Finn, "Hey, let\'s go on an adventure?"'; const badStr = 'Finn responds, "Let's go!"';
Here badStr will throw an error.
Quotes are not the only characters that can be escaped inside a string. Escape sequences allow you to use characters you may not otherwise be able to use in a string.
Code Output
\’ single quote
\” double quote
\\ backslash
\n newline
\t tab
\r carriage return
\b word boundary
\f form feed
In JavaScript, when the + operator is used with a String value, it is called the concatenation operator. You can build a new string out of other strings by concatenating them together.
'My name is Alan,' + ' I concatenate.'
Note: Watch out for spaces. Concatenation does not add spaces between concatenated strings, so you’ll need to add them yourself.
const ourStr = "I come first. " + "I come second.";
We can also use the += operator to concatenate a string onto the end of an existing string variable. This can be very helpful to break a long string over several lines.
Note: Watch out for spaces. Concatenation does not add spaces between concatenated strings, so you’ll need to add them yourself.
Example:
let ourStr = "I come first. "; ourStr += "I come second.";
Sometimes you will need to build a string. By using the concatenation operator (+), you can insert one or more variables into a string you’re building.
const ourName = "freeCodeCamp"; const ourStr = "Hello, our name is " + ourName + ", how are you?";
Just as we can build a string over multiple lines out of string literals, we can also append variables to a string using the plus equals (+=) operator.
const anAdjective = "awesome!"; let ourStr = "freeCodeCamp is "; ourStr += anAdjective;
You can find the length of a String value by writing .length after the string variable or string literal.
console.log("Alan Peter".length);