Saturday, February 21, 2015

Day 75: Head First Javascript

All right, so now that I'm refocused, today's work began with the Head First Javascript book.  I already had an idea of what compiling meant, but the book defined it.  Compiling is the process through which your code goes through which produces a machine efficient representation of it, usually optimized for runtime performance.  With conventional languages like C, C++, or Java, you compile the code before you execute it.  Scripting languages, like javascript, are typically interpreted, which means the browser runs each line of code as it gets to it.  Scripting languages place less importance on runtime performance, and are more geared towards tasks like prototyping, interactive coding, and flexibility.  In the early days of javascript, performance was not so great due to this, but in recent years however, browser manufacturers have made it so that javascript, an interpreted language, can be compiled on the fly.

So, with javascript, you now have the conveniences of a scripting language, while enjoying the performance of a compiled language.  The word ECMA Script will pop up every so often when learning about javascript.  ECMAScript is the standard language definition for all javascript implementations.  The current implementation is ECMAScript 5, and ECMAScript 6 is currently being worked on.

A keyword is a reserved word in javascript, like var, function, true, false, break, or delete, for example.  We cannot use these keywords as names for variables.  In javascript, case does matter, so if we use two sample variable names, thisVariable and thisvariable, they would be treated as two different variables.  Although we are allowed to begin variable names with _ and $, we should avoid doing so.  

We wrote a simple function:

var total3 = 3
var total5 = 5

function finalTotal() {
document.write(total3 * total5);
}

finalTotal();

We went over while loops, and this reminded me of my Project Euler problem, which I need to solve, so I started working on a solution.  My first Project Euler Problem is this: 

If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.  Find the sum of all the multiples of 3 or 5 below 1000.

This is what I have so far:

 Multiples of 3

i = 0
while (i < 999) {
var i = i + 3;
document.write(i);
}

Multiples of 5

i = 0
while (i < 999) {
var i = i + 5;
document.write(i);

}

So, I'm able to get the necessary numbers to appear on the screen, but I have to figure out how to add the result of each loop iteration to the result of the prior loop iteration, and then, add the results of both loops to each other.  It's a start!

I learned that DOM stands for Document Object Model, but we didn't go into what exactly this means.

SUMMARY OF CODING SKILLS

Total Treehouse Points: 5,151

Treehouse Points by Subject Matter (Miscellaneous not included): 
HTML:                                663 
CSS:                                1,599 
Design:                            1,193 
Development Tools:            747 
Javascript:                         916

Treehouse Ranking (%): "You have more total points than 91% 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 29)

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: 4.5
Total Hours Coding: 361

No comments:

Post a Comment