Wednesday, March 25, 2015

Day 82: The Odin Project is Launching a Code School!!! And Solved Another Euler Problem!

I'm continuing with the javascript book today, with the goal being to finish the book, then attempt the second and third Euler Problem, perhaps also finish the Head First Book as well, and then move on to the next part of The Odin Project.  I started today on page 33, chapter 8, which deals with concatenating text strings.  

This alert:

alert("2" + "2");

Creates an output of 22, because javascript will concatenate the strings.

When creating an alert like this:

alert("2 plus 2 equals " + 2 + 2);

The resulting alert will read "2 plus 2 equals 22" because javascript converts the numbers to strings in the alert's output.  The next chapter, chapter 9, deals with prompts.  In a prompt, you need a way to capture the user's response, and that means you need to start by declaring a variable, followed by an equal sign.  In a prompt, you can specify a second string, and this appears as the default response in the field when the prompt displays.  If the user leaves the default response as-is and just clicks OK, the default response is assigned to the variable.  A default response is not required, and it the variable does not have to be named defaultAnswer, but here is an example using default Answer as the variable name, for clarity:

var question = "Your species?";
var defaultAnswer = "human";
var spec = prompt(question, defaultAnswer);

The user's response will be a text string, and even if the user's response is a number, it will be converted into a string once the response is assigned to the spec variable.  If there is no default answer assigned, and the user enters nothing, the variable will be assigned the value of an empty string, as in, "".  If the user clicks cancel, the variable is assigned a special value, null.

I'm now on chapter 10, which goes over "if" statements, but several amazing things have happened today that I've got to go over!  

First, I solved Euler Problem 2!  The answer came to me again like last time!  I love how I can be thinking about something else, and then my mind wanders back to javascript, and I think of whatever problem I'm facing from a different angle, then a light goes on in my head, and I think, "Wait!  This could work!"  Then I rush over to my laptop to translate the concept into code, and then, there it is, the answer I'd been looking for!  I love coding!

I used an array to create the fibonacci sequence, and I printed the array onto the page with document.write, just to see it, and I printed the answer to the console, but I could have simply printed the answer to the page instead.  Here's my solution:

var fibArray = [1,2];
var total = 2;

    for (var i = 0; i < 30; i += 1) {
    var fib1 = fibArray[fibArray.length - 2]
var fib2 = fibArray[fibArray.length - 1]
    var fib = fibArray[fibArray.length - 1] + fibArray[fibArray.length - 2];
    fibArray.push(fib);  
    if (fib % 2 === 0) {
    total = total + fib;
   
    }

    document.write(fibArray)
    console.log(total);

The answer comes out to 4613732.  Yes!  

The second piece of great news is that The Odin Project is launching an online coding school!!!!  I was socializing in my backyard with some friends, while running javascript in the back of my mind, when I received an email on my smartphone spreading the news!  I know!  My mind is blown also!!!  It's like the fates aligned today!  I'm applying on my other monitor as I type this!  I wrote a comment on the blog announcement letting them know I plan on applying and making my case for why I'd be a solid candidate, which I think I am.

O.k., submitted the application.

Next, I planned on working on Euler Problem 3, which requires me to find out the largest prime factor of the number 600851475143, however, it turns out that there is some prep work I should be doing to enhance my application to The Odin Project's online coding school, so, I'm going to interrupt my current course of action and get back to it after I finish the prep work.  Going over it, but it's 5:25 a.m. now, I was so stoked by the online coding school application that I stayed up all night working on it.  I'm going to go to bed now and start on the prep work later today.

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

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

No comments:

Post a Comment