Discovering Dev Tools

I just completed the Discover Dev Tools course over at Code School and I think that it was extremely informative and helpful. I highly recommend going through this if you’re not already familiar with Chrome’s Developer Tools.

This was an option assignment before week one of the Learn JS Properly Study Group, but I found that i didn’t understand a lot of it on my first run. I decided to put this on hold and complete the Web Fundamentals Track first. Good decision. After more exposure with CSS, I found it much easier to follow.

Dev Tools is very powerful and it will be a while before I will be able to use it for its full potential. Beyond editing DOM elements, CSS, and Javascript, Dev Tools has other debugging and performance capabilities that are pretty slick.

Go check it out!

10 Day Codecademy Streak!!

Score!

streak10

Now I know this doesn’t really mean much. I even went as far as to say in my first post that I thought Codecademy was lacking in some areas. Nonetheless, I have to say that working on the exercises often helps me to remember everything.

I worked through the Web Fundamentals Track for week 1 of my study group and I have retained most of the concepts. One thing that helps me to is to delete and type out some of the things that Codecademy automatically gives you like:

<link type="text/css" rel="stylesheet" href="stylesheet.css/>

Even though this doesn’t change from exercise to exercise, I’m sure it will be good to have this tag memorized.

Now lets see how long I can keep this streak going!

EDIT: I got to 11 days, haha. I went drinking on Friday after work and was too hungover on Saturday to think about looking at code. Oh well, it was fun while it lasted. Back on it today!

Learning JS Properly – Week 2

Week two was just announced, and here are the assignments for the week!

  1. Read chapters 3, 4, and 5 of JavaScript: The Definitive Guide OR chapters 3 and 4 and the preface of Professional JavaScript for Web Developers.
  2. Work through sections 2 – 5 of the JavaScript track on Codecademy.
  3. Solve either Project Euler Problem 1 or Problem 2. Feel free to solve both.
  4. To prepare for Week 3, read the blog post JS Objects in Detail. If you want to work ahead, this is the general roadmap I’m using to make these assignments.

Don’t forget: You should be typing out lots of example code in the console or in JSFiddle. You’re not going to learn nearly as much if you don’t actually type it out with your own fingers.

I’ve been using jsFiddle as my IDE for working through the problems, and one thing I really like about it is that I can practice my HTML and CSS as well! It’s helping me to figure out exactly how they work together with Javascript and how to manipulate the DOM.

In this post, mr_noah is posting his answer to the Project Euler practice problems and he uses the following code to output his sum to the document body:

$("body").append("<p>runningTotal = "+runningTotal+"</p>");

I tried to do the same, but it didn’t seem to work. I then realized he had imported a JQuery library. I wanted to use pure JS, so I went to trusty Google and found a solution that worked without using JQuery:

var para=document.createElement('p');
var node=document.createTextNode('Sum = ' +sum);
para.appendChild(node);
document.body.appendChild(para)
console.log(document.body);</span>

It feels really good to see everything coming together! I used some of the CSS that I learned from Codecademy just to dress up my output page a bit. See my solutions to the Project Euler Problem 1 and Problem 2.

I’ll post the full Week 2 review review once I finish up the rest of the assignments. Cheers!

Learning JS Properly – Study Group Index

Edit: Thanks for stopping by visitors from the Reddit study group! I’ve moved my blog on over to my own domain over at codingisbananas.com. Come visit me over there for all new posts!


Here’s a compilation of all of the links for the course which I’m using to keep organized. I’ll keep it updated as the weeks progress.

Announcement and Index on Reddit:

Assignment Posts:

Week 2 Discussions: [CURRENT]

Week 0 Discussions:

Week 1 Discussions:

Learning JS Properly – Week 1 Review

Week 1 of the Javascript Study Group has come to an end, and I have to say that I’ve really been good about working on the assignments and I’m really excited to keep going!

Here’s a list of the first week’s assignments again:

  1. If you don’t know HTML/CSS pretty well, do the Web Fundamentals track on Codecademy.
  2. Read the Preface and Chapters 1 and 2 of JavaScript: The Definitive Guide OR read the Introduction and Chapters 1 and 2 of Professional JavaScript for Web Developers.
  3. Work through section 1 of the JS Track on Codecademy.
  4. Make a least one comment in this thread about something you learned, found interesting, or didn’t understand very well.

My Progress:

  1. This is the assignment that has probably taken up the most time for me. It’s not the difficulty of it, its just that there are a lot of exercises. I still have about a third of the way to go but I will definitely finish this up this week.
  2. I chose to read Professional JavaScript for Web Developers and I found the reading to be quite interesting. While I’ve had exposure to the programming of Javascript, I haven’t really had much exposure to how Javascript works with together with HTML and the DOM and BOM. Chapter 2 really helped me to connect the dots with all of this.One specific thing I got out of this was that you sometimes don’t want your Javascript to load before the page begins rendering because the wait time results in a perceived slowness to your page. This can be accomplished by adding a defer or async attribute to your <script> tag or including the JS in the <body>. Each behaves its own way.
  3. This last assignment was pretty simple as I’ve completed the Javascript Original Track already. I did have fun with the last exercise though. Below is the code I wrote. It prompts the user to enter a number and only displays the string required to pass the lesson when their entry number is divisible by both 3 and 5.

var finish = "I finished my first course!";

function fizzBuzz(num){
    if(num%3 === 0){
        if(num%5 === 0){
            return 'fizzbuzz';
        } else {
            return 'fizz';
        }
    }else if(num%5 === 0){
        return 'buzz';
    }else
        return 'not fizzin or buzzin';
}

var input = "";
do {
    input = prompt("Gimme some fizzbuzz.(fizz is a multiple of 3, buzz is a multiple of 5)",'write here');
    console.log(fizzBuzz(input));
    if(fizzBuzz(input)==="fizzbuzz"){
        console.log(finish);
        break;
    }
}while (true);

There were a few questions that people asked on the subreddit and I commented on a few of them. Here is an index of all posts related to the study group. So far many of the questions were regarding Eloquent Javascript, which can be very dense at times. I think as we move forward and the assignments start to get more difficult, the discussions will become more involved.

That’s it for now! Looking forward to starting on Week 2!!!

Learning JS Properly

Looks like I’m going to begin another course! …well, study group actually.

A good friend of mine, who’s been a professional coder for a few years, suggested that I make sure I completely learn Javascript if I am to seriously consider breaking in to the world of Web Development. He gave me a link to a 6-8 week JS study roadmap, which I coincidentally had already found. There is a study group that just started on Monday at /r/learnjavascript that I’m going to take an active role in.

I’m really excited to get to work and really bolster my knowledge! I think having a bit of structure and knowing that other people are going to be doing this with me is both encouraging and motivating. I hope to be able to collaborate with people and get help while also helping others throughout the remainder of the course. Below is what I’ll have to do for week 1. I’ll be back when I’m done to make some comments on the assignments.

FIRST WEEK ASSIGNMENTS:

  1. If you don’t know HTML/CSS pretty well, do the Web Fundamentals track on Codecademy.
  2. Read the Preface and Chapters 1 and 2 of JavaScript: The Definitive Guide OR read the Introduction and Chapters 1 and 2 of Professional JavaScript for Web Developers.
  3. Work through section 1 of the JS Track on Codecademy.
  4. Make a least one comment in this thread about something you learned, found interesting, or didn’t understand very well.

Cheers!

daysOld.py

I’m taking Udacity’s Intro to Computer Science and there was a good problem in Problem Set 2 (optional 2): Given your birthday and the current date, calculate your age in days. Account for leap days. Assume that the birthday and current date are correct dates (and no time travel).

All it gave you was the following procedure definition:

def daysBetweenDates(year1, month1, day1, year2, month2, day2):

The algorithm i used to solve my solution was:

Step 1: Figuring out the number of whole years have elapsed. Taking into account that if month2 was less than month1, you essentially have to borrow days from the prior year and subtract 1 from the value of year2-year1.

Step 2: Figuring out how many days have passed in the months not part of the full years. (Current date days are positive, and birth date days are negative. The sum of the two give the number of days elapsed outside of the full years.)

Step 3: Convert the years to days and add it all together including the extra days from leap years.

Here is the finished code from the primary procedure:


def daysBetweenDates(year1, month1, day1, year2, month2, day2):
    ##
    # Your code here.
    ##
    monthDays = 0

    fullYears = year2-year1
        if month2<month1:
        fullYears -= 1
        monthDays += 365

     monthDays = monthDays + daysFromMonths(month2) + day2 - daysFromMonths(month1) - day1

     daysOld = fullYears*365 + monthDays + leapDays(year1,month1,year2,month2)
     return daysOld

Step 1 was pretty straight forward and didn’t require an additional procedure for the calculation, but step 2 did. My aim was to be able to calculate the number of days have past in the year for any given month so that I could subtract the total days from date2 by the total days from date1 (excluding the days from full years).

That was accomplished by creating a procedure that was able to calculate the number of days in a year have passed up to a specified month. This procedure contained an array with the number of days in each month. When called, it looped through the array summing the days in every month until reaching the month parameter passed into the procedure.

The days from the full years were added to the days from the months and then finally the extra days for the leap years were added.

You can see my full solution on my Github account, here.

I ran into one speedbump because I assumed that leap years were all years divisible by 4. The last test case kept failing so I knew something was wrong. It turned out that my leap year assumption was wrong. From Wikipedia, it is actually:

if year is divisible by 400 then
   is_leap_year
else if year is divisible by 100 then
   not_leap_year
else if year is divisible by 4 then
   is_leap_year
else
   not_leap_year

Once i added a procedure that accounted for this, my solution was correct!

Where I Stand…

…in the realm of programming and what got me here.

I’ve taken a few formal classes on Java back in University that has given me somewhat of a foundation to the art. More recently I’ve completed the first 6 sections of Eloquent Javascript, have mostly completed the Javascript Original Track in Codecademy, and am currently enrolled in Udacity’s Intro to Computer Science (Python) course.

Eloquent Javascript (EJ) was the first thing I worked on, and it was a very good brain work out. It especially took me a little while to wrap my head around objects, but I think that EJ does a really good job in letting you work through problems and try different things. I definitely logged many hours working through the lessons and making sure that I grasped the fundamentals that they were trying to teach me.

Codecademy has some pros and cons for me. When I first found out about it, I was pretty stoked and I can honestly say that it re-lit a fire under me to work more on programs. The whole gamification aspect to it can be motivating. But they really don’t let you figure enough out on your own. I feel like I always forget the concepts they teach because there just isn’t enough exposure to different programming concepts.

I’m taking the Udacity course because I wanted projects to work on. Codecademy wasn’t teaching me what I wanted to learn. So far its been a good intro into python. Things aren’t getting too hard yet, but there was one problem in the second problem set that really got my mind working.

The problem was to create a procedure that: Given your birthday and the current date, calculate your age in days. Account for leap days. Assume that the birthday and current date are correct dates (and no time travel).

In my next post, I will talk a little bit about the problem and the challenges I faced.