Chapter 23 is a bit confusing, so I was re-reading it yesterday, and that's where I started today. I re-read the code that begins the chapter (well, this is my version of it, but it works too):
var text = "Hello, this is sample lorem impsum text that I am typing in order to have a paragraph of text to fill out the text variable. Basically this paragraph deals with World War II. We are not supposed to use that name, and the code below should change it to Second World War. Let's see if it does!";
for (var i = 0; i < text.length; i++) {
if (text.slice(i, i + 12) === "World War II") {
text = text.slice(0, i) + "the Second World War" +
text.slice(i + 12);
}
};
And this time I understood it. Where text is redefined, the new definition concatenates everything before the insertion, the insertion, and everything after the insertion.
It helps a lot when, before you start reading, you say to yourself: "I will read this, and I will pay attention, and I will understand it, and if I don't, i will read it again until I do." I find that what happens a lot when I do that is that I understand it the first time. Focus is key to this stuff.
I completed Chapter 23, and am now on Chapter 24. I completed Chapter 24 and now I'm on Chapter 25. Here, I learned the replace method, which works like so:
var newText = text.replace("World War II", "the Second World War");
That's much more efficient than the for loop and slice approach or the indexOf and slice approach (the one with the !== - 1 as the condition for the for loop). That will replace only the first instance. If you want to replace all instances, the code is like so:
var newText = text.replace(/"World War II"/g, "the Second World War");
If we use a new variable on the right, then the original variable will remain the same. If we use the same variable, like so, then the original will be changed:
var text = text.replace(/World War II/g, "the Second World War");
Notice that the quotation marks are removed from the first string.
I finished Chapter 25 and am now on Chapter 26 Rounding Numbers. The Math.round function rounds up. The M must be capitalized. For example, .5 would be rounded up to 1, while -1.5 would be rounded up to -1. Math.ceil rounds up to the nearest integer no matter what, so .000001 becomes 1, while -1.0000005 becomes -1 and so on. Math.floor does the opposite, it rounds down to the nearest integer, so .000001 becomes 0, while -1.000005 becomes -2.
I finished Chapter 26 and am now on Chapter 27.
SUMMARY OF CODING SKILLS
var text = "Hello, this is sample lorem impsum text that I am typing in order to have a paragraph of text to fill out the text variable. Basically this paragraph deals with World War II. We are not supposed to use that name, and the code below should change it to Second World War. Let's see if it does!";
for (var i = 0; i < text.length; i++) {
if (text.slice(i, i + 12) === "World War II") {
text = text.slice(0, i) + "the Second World War" +
text.slice(i + 12);
}
};
And this time I understood it. Where text is redefined, the new definition concatenates everything before the insertion, the insertion, and everything after the insertion.
It helps a lot when, before you start reading, you say to yourself: "I will read this, and I will pay attention, and I will understand it, and if I don't, i will read it again until I do." I find that what happens a lot when I do that is that I understand it the first time. Focus is key to this stuff.
I completed Chapter 23, and am now on Chapter 24. I completed Chapter 24 and now I'm on Chapter 25. Here, I learned the replace method, which works like so:
var newText = text.replace("World War II", "the Second World War");
That's much more efficient than the for loop and slice approach or the indexOf and slice approach (the one with the !== - 1 as the condition for the for loop). That will replace only the first instance. If you want to replace all instances, the code is like so:
var newText = text.replace(/"World War II"/g, "the Second World War");
If we use a new variable on the right, then the original variable will remain the same. If we use the same variable, like so, then the original will be changed:
var text = text.replace(/World War II/g, "the Second World War");
Notice that the quotation marks are removed from the first string.
I finished Chapter 25 and am now on Chapter 26 Rounding Numbers. The Math.round function rounds up. The M must be capitalized. For example, .5 would be rounded up to 1, while -1.5 would be rounded up to -1. Math.ceil rounds up to the nearest integer no matter what, so .000001 becomes 1, while -1.0000005 becomes -1 and so on. Math.floor does the opposite, it rounds down to the nearest integer, so .000001 becomes 0, while -1.000005 becomes -2.
I finished Chapter 26 and am now on Chapter 27.
SUMMARY OF CODING SKILLS
Total Treehouse Points: 5,385
Treehouse Points by Subject Matter (Miscellaneous not included):
HTML: 663
CSS: 1,599
Design: 1,193
Development Tools: 747
Javascript: 1,120
Treehouse Ranking (%): "You have more total points than 94% of all students."
Treehouse Badge(s) Earned Today:
Treehouse Courses Completed:
How to Make a Website
HTML
CSS Foundations
CSS Layout Techniques
Aesthetic Foundations
Design Foundations
Adobe Photoshop Foundations
Adobe Illustrator Foundations (66% complete, switched focus from web design to web dev)
Git Basics
Introduction to Programming
Javascript Basics
Codecademy (& other) Courses Completed:
HTML and CSS (Codecademy)
Design Foundations
Adobe Photoshop Foundations
Adobe Illustrator Foundations (66% complete, switched focus from web design to web dev)
Git Basics
Introduction to Programming
Javascript Basics
Codecademy (& other) Courses Completed:
HTML and CSS (Codecademy)
Books Read or in Progress:
Completed: "Head First HTML and CSS," by E. Robson & E. Freeman
In Progress: "Eloquent JavaScript," by Marijn Haverbeke (On pg 27)
In Progress: "Head First Javascript," by Eric Freeman and Elisabeth Robson (On pg 56)
In Progress: "A Smarter Way to Learn Javascript," by Mark Myers (on pg 89)
My Progress on The Odin Project:
1. Introduction to Web Development 100% Complete
2. Web Development 101 29% Complete
3. Ruby Programming 0% Complete
4. Ruby on Rails 0% Complete
5. HTML5 and CSS3 0% Complete
6. Javascript and JQuery 0% Complete
7. Getting Hired as a Web Developer 0% Complete
Hours Spent Coding Today: 2
Total Hours Coding: 555
No comments:
Post a Comment