I think I say, “Merlin, NO!”, about a few hundred times a day! He is certainly a bundle of energy and into everything. He is sleeping at the moment, so I have some time to rest and do more coding. I’m watching him while Karissa showers and then she will take him back and watch him.
Chris moved back to his dorm today. Alexis moves back on the 27th. It’s a week late due to her internship but she got the ok with the school that she can be a week late. She still has to log in to her classes to check them out and do her online classes. The Sunday we take her back is going to be a day! We have to first pack up the truck with her stuff, we are taking Alex along with us cause Tommy can’t help cause of his neck and he is still healing from surgery, and then go up to Lexi’s apartment and move her out. Then go up to her university three and a half hours away and move her into her dorm. It’s going to be a hell of a day. I hope the weather is good. When we moved Lexi out of her dorm for the summer, it rained the whole time.
Oh, next year we are having another Alaskan cruise. This trip will be 14 days with a few new ports. I’m excited. The trip will be longer so it will be more time to relax. And we get to see some new places. I think we are seeing more glaciers too. Maybe we will get a chance to see the Northern Lights.
Saw the Isotopes, minor league baseball team, last night. They won! Tommy and I got our steps in by walking around the perimeter of the stadium three times. My legs get tired too easily. I’m hoping the more I walk, the stronger my legs become. I need better shoes too. I wore my Vans a few times walking and it gave me a blister. So I’m back to my other shoes that aren’t the greatest for walking but it does the job and I can’t feel my blister in them.
I’m excited that we’re about to enter my favorite time of year. Fall. Summer is nice, I like the heat. Sometimes. I don’t like the bugs. I just want to be back in a sweater and enjoying some hot chocolate. Halloween is coming and I have to try not to eat so much candy. I’m trying to be good.
I best be going now. More coding to do and I took too long of a break to write this.
JavaScript notes…
———————————————
Say you want to match a word that occurs multiple times like below.
let repeatStr = "row row row your boat";
You could use /row row row/, but what if you don’t know the specific word repeated? Capture groups can be used to find repeated substrings.
Capture groups are constructed by enclosing the regex pattern to be captured in parentheses. In this case, the goal is to capture a word consisting of alphanumeric characters so the capture group will be \w+ enclosed by parentheses: /(\w+)/.
The substring matched by the group is saved to a temporary “variable”, which can be accessed within the same regex using a backslash and the number of the capture group (e.g. \1). Capture groups are automatically numbered by the position of their opening parentheses (left to right), starting at 1.The example below matches a word that occurs thrice separated by spaces:
let repeatRegex = /(\w+) \1 \1/; repeatRegex.test(repeatStr); // Returns true repeatStr.match(repeatRegex); // Returns ["row row row", "row"]
Using the .match() method on a string will return an array with the matched substring, along with its captured groups.
Searching is useful. However, you can make searching even more powerful when it also changes (or replaces) the text you match.
You can search and replace text in a string using .replace() on a string. The inputs for .replace() is first the regex pattern you want to search for. The second parameter is the string to replace the match or a function to do something.
let wrongText = "The sky is silver."; let silverRegex = /silver/; wrongText.replace(silverRegex, "blue");
The replace call would return the string The sky is blue..
You can also access capture groups in the replacement string with dollar signs ($).
"Code Camp".replace(/(\w+)\s(\w+)/, '$2 $1');
Write a regex fixRegex using three capture groups that will search for each word in the string one two three. Then update the replaceText variable to replace one two three with the string three two one and assign the result to the result variable. Make sure you are utilizing capture groups in the replacement string using the dollar sign ($) syntax.
Both Chrome and Firefox have excellent JavaScript consoles, also known as DevTools, for debugging your JavaScript.
You can find Developer tools in your Chrome’s menu or Web Console in Firefox’s menu. If you’re using a different browser, or a mobile phone, we strongly recommend switching to desktop Firefox or Chrome.
The console.log() method, which “prints” the output of what’s within its parentheses to the console, will likely be the most helpful debugging tool. Placing it at strategic points in your code can show you the intermediate values of variables. It’s good practice to have an idea of what the output should be before looking at what it is. Having check points to see the status of your calculations throughout your code will help narrow down where the problem is.
Here’s an example to print the string Hello world! to the console:
console.log('Hello world!');
You may have noticed that some freeCodeCamp challenges include their own console. This console behaves a little differently than the browser console.
There are many methods to use with console to output messages. log, warn, and clear to name a few. The freeCodeCamp console will only output log messages, while the browser console will output all messages. When you make changes to your code, it will automatically run and show the logs. The freeCodeCamp console is then cleared each time your code runs.
You can use typeof to check the data structure, or type, of a variable. This is useful in debugging when working with multiple data types. If you think you’re adding two numbers, but one is actually a string, the results can be unexpected. Type errors can lurk in calculations or function calls. Be careful especially when you’re accessing and working with external data in the form of a JavaScript Object Notation (JSON) object.
Here are some examples using typeof:
console.log(typeof ""); console.log(typeof 0); console.log(typeof []); console.log(typeof {});
In order, the console will display the strings string, number, object, and object.
JavaScript recognizes seven primitive (immutable) data types: Boolean, Null, Undefined, Number, String, Symbol (new with ES6), and BigInt (new with ES2020), and one type for mutable items: Object. Note that in JavaScript, arrays are technically a type of object.