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!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s