Thursday, January 1, 2015

Day 63: Codecademy Javascript Course

I've been preoccupied with the holidays, as my family flew to New York for Christmas/New Years.  I've been squeezing some coding in here and there, working on a Codecademy Javascript course, to complement the "Introduction to Programming" course on Treehouse, which is also on Javascript.

In Javascript, when we want a line of text to be ignored, we start the line off with two forward slashes, like so: 

//

Data comes in various types, including numbers and strings.  Numbers are self-explanatory, while strings are sequences of characters.  Another date type is the boolean, which is a data type having two values (usually denoted true and false).  Equal to is represented by ===, while !== means not equal to.  Greater than is >, less than is <, while greater than or equal to is >= and less than or equal to is <=.

If we enter:

confirm("Would you like to enter?")

A popup will appear on the page with the text and the options to hit cancel or ok.  If the user hits cancel, a "false" will be output into the console, if the user hits ok, a "true" will be output into the console.  Multiple sequential confirm lines will create multiple sequential popups.  We can use a semicolon at the end of each grouped line of code to separate the next group of code from the one prior.

I went over Modulo, which returns the remainder of two numbers that are divided, like so:

5 % 2

Would return a 1, as 2 goes into 5 2 times, with a remainder of 1.  If we do:

30 % 10

Then we would get a result of 0, because the remainder is 0.  I input this into the course:

if( 10 % 2 === 0) {
    console.log("The first number is even");
} else {
    console.log("The first number is odd");
}

And the output was "The first number is even," which means that the input evaluated to "true."  

I entered this:

if (15>4) {
    console.log("Adan is cool");
}

In order to print out "Adan is cool" in the log.

I entered this:

console.log("January".substring(0, 3));
console.log("Melbourne is great".substring(0, 12));
console.log("Hamburgers".substring(3, 10));

In order to print out:

Jan
Melbourne is
burgers

The .substring returns the desired letters.  "0" is the spot before the first letter, while "1" is the spot after the first letter, and so on, so for the letter you want to begin at, you enter the number before it (0 for the first letter, 1 for the second, and so forth), while for the letter you want to end at, you enter the number of the letter, because the number to the right of the letter corresponds to one below it's place in the sequence, while the number to the right of the letter is the same as the letter's place in the sequence of letters or spaces.

Here's a conditional statement:

if ( "Adan Camacho".length < 5) {
     console.log("Let's go down the first road!");
}
else {
     console.log("Your name is greater than 5 letters!");
}

We use variables to store data types.  For example:

var myCountry = "England"

Would store the string "England", which is a data type, inside the variable myCountry.  So then if I entered this:

console.log(myCountry.length)

The output would be 7, because England has seven characters.  Notice that myCountry is not in quotation marks, because it's a variable, as opposed to a string.

Then I entered this code for the final question:

if ("John".length > 5) {
     console.log("Apple");
}
else {
     console.log("I finished my first course");
}

The output was "I finished my course", which was the last part of the first Javascript course on codecademy.  I then went through this course once more, just to refresh the concepts, since I had been working on the course in small increments, sporadically, during the holidays, and I found this review to be tremendously useful.

SUMMARY OF CODING SKILLS

Total Treehouse Points: 4,236

Treehouse Points by Subject Matter: HTML 663, CSS 1,599, Design 1,193, Development Tools 747, and Miscellaneous
Treehouse Ranking (%): "You have more total points than 88% 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, but switched focus to web dev, as opposed to web design)
Git 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 (37 pg preface and 710 pgs of actual content (as in, I'm not including the book's index))

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

No comments:

Post a Comment