Wednesday, July 22, 2015

Day 122: Chapter 41 of the JavaScript Book

I began today with Chapter 41 of the JavaScript book.  Chapter 14 goes over while loops.  Here's an example:

var i = 1;
while (i < 6) {
  alert("We're on iteration " + i + "!")
  i++;


The code above makes an alert appear on the screen which shows which iteration the loop is on.  The loop makes 5 iterations, and then stops.

Next was Chapter 42 Do...while loops.  Do...while loops are very similar to while loops, but they have a different format, like so:

var i = 0;
do {
  alert(i);
  i++;
} while (i < 0) ;

Because the while statement is at the end of the Do...while loop, the loop will always run at least once, unlike the while loop, which would not run even once using the conditions above, because i is not less than 0 to begin with.  

All right, I finished that chapter and moved on to Chapter 43 Placing Scripts.  It kind of seems like I'm finally getting to the good stuff.  I've been learning a lot of JavaScript code, but it's all just logic and math, which is a fun game, but I haven't yet seen JavaScript code actually applied to a website to do anything really useful.  I've seen code that is supposed to do neat little games, like the 99 bottles of beer on the wall game I coded, but that's about it.  I'm looking forward to applying my JavaScript knowledge to make some fun things with some kind of utility that I can actually deploy.

So Chapter 43 dealt with placing scripts.  One is to link to an external JavaScript file, like so:

<script src="thefile.js"><script>

Another way is to insert the code in the actual html file, like so:

<body>
<script>
alert("hahaha");
</script>
</body>

The chapter says we should place both JavaScript inserted directly into the html and JavaScript inserted via a link to an external file, at the end of the body section (before the closing body tag).  This allows the body content, like images and such, to load before the browser attempts to load the JavaScript.

The next chapter was Chapter 44 Commenting, which dealt with how to comment in your code.  It was a quick read, // will comment out everything to the right of it on that specific line of the file, while /* and */ will comment out every line between the first and second forward slash. 

In html, we can comment by inserting our comments into this: 

<!-- comment here -->

In CSS, we can comment by using the /* and */.  JavaScript files tend to be more complicated than html or CSS, so we should leave very good comments, to aid others who may later work on our code and need to know why we did what we did and what does what.

All right, that's enough coding for the day.  I'm going to go study Tagalog for an hour or so.  I speak English and Spanish fluently, and I decided to learn Tagalog (the main language of Manila, the capital of the Philippines) as a fun activity to add to my life.  I started yesterday, and my plan is to get an hour of Tagalog in a day (I'm learning with Rosetta Stone).  I try to do two hours of coding a day, and sometimes I get more done, but if I do a minimum of two hours a day, it keeps my mind in coding mode, and I maintain my momentum.  Since this method is working really well since I adopted it about a week ago with coding, I thought I'd apply it to learning Tagalog as well. 

Tomorrow, I'll start with Chapter 45 Events: Link.

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) 

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 148)

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:3
Total Hours Coding: 574

No comments:

Post a Comment