Craig Rodrigues!

Learning to Code: Week 21 - Eloquent Javascript

TOTAL 🍅  THIS WEEK: 36

Goals For This Week:

  1. Finish Frontend Masters “Introduction to JavaScript Programming”
  2. Finish Chapters 1-4 in Eloquent JavaScript
  3. Email 10 people on my alumni list
  4. Finish CS50 Problem Set 7 (if time or need a break from JS)

September 30, 2016 🍅🍅

October 01, 2016 🍅🍅🍅

    • Eloquent JavaScript (EJS): Introduction
    • EJS Chapter 1: Values, Types and Operators
      • JS numbers are fixed at 64 bits, unlike C.
      • JS has special numbers like Infinity and -Infinity and also NaN ("not a number" or something like 0/0)
      • The above is weird. || does the opposite. It is called short-circuit evaluation.

image01

    • EJS Chapter 2: Program Structure
      • Sometimes you need a ; and sometimes you don’t when closing a statement. The book with always use a ; if needed to avoid weird cases you can learn later.
      • Variable names can be any word that isn’t reserved (var, debugger, etc are reserved)
      • Variables
        • Cannot contain spaces
        • Cannot start with a digit.
        • No punctuation except $ and _
      • Do not need to initialize a variable or allocate memory like in C (LIC).
      • You can assign variables on one line if you wish separated by commas.
        • var x = 1, y = 2;
      • This is one of the coolest parts of Javascript to me!
  • In browsers, the output lands in the JavaScript console. This part of the browser interface is hidden by default, but most browsers open it when you press F12 or, on Mac, when you press Command-Option-I. If that does not work, search through the menus for an item named “web console” or “developer tools”.
      • I tried it and could immediately start coding what was in the book and get results. Crazy.
      • I know the google developer tools are an entire career in itself.
      • Also the online book is so awesome. You can click on a code snippet and manipulate and run it right there. Seems magical. I do have a print copy as well though for when I do not have computer access (and it feels nice in the hand).

image03

    • The function Number converts a value to a number. We need that conversion because the result of prompt is a string value, and we want a number. There are similar functions called String and Boolean that convert values to those types.
    • Variable names: usually capitalize every word except the first. So helloWorld instead of hello_world or HELLOWORLD.

Looping a Triangle

Write a loop that makes seven calls to console.log to output the following triangle:

#
##
###
####
#####
######
#######

It may be useful to know that you can find the length of a string by writing .length after it.

Solution:

for (var blocks = "#"; blocks.length <= 7; blocks += "#")
  console.log(blocks);

String concatenation is very useful here. In C it requires nested loops. I also didn’t quite realize how to use length until after looking at the solution.

October 02, 2016 🍅🍅🍅🍅

  • How to learn programming without getting stuck
    • I believe the most difficult part of learning new programming is not the very first step.
    • However, once you want to go on to the next step – for example, you want to build something out of your idea – you easily get lost.
    • Find a mentor from Upwork
    • At the time, I thought I could use Codementor https://www.codementor.io/ to ask experts about what to do next. But I realized it is a bit expensive to find a long-term mentor there.
    • Basically, I did pair programming with my chosen mentor for 2 hours per session and reviewed it afterwards alone.
    • It was the most efficient learning experience since I didn’t get stuck at all thanks to his help, even though there was a great deal I didn’t know about Ruby on Rails and backend server coding.
  • EJS Ch.1 Problems Continued
    • FizzBuzz
    • Write a program that uses console.log to print all the numbers from 1 to 100, with two exceptions. For numbers divisible by 3, print "Fizz" instead of the number, and for numbers divisible by 5 (and not 3), print "Buzz" instead.
    • When you have that working, modify your program to print "FizzBuzz", for numbers that are divisible by both 3 and 5 (and still print "Fizz" or "Buzz" for numbers divisible by only one of those).
    • The book’s solution is much more elegant and straightforward to me. It also took advantage of the || to return a default value if neither condition before was met.
    • It also concatenates the strings “Fizz” and “Buzz” instead of just checked if it is divisible by 15 first! I never would have thought of this. Concatenating strings is something very new from C.

MINE

for (var i = 1; i <= 100; i++) {
  if (i % 15 == 0)
    console.log("FizzBuzz");
  else if (i % 3 == 0)
    console.log("Fizz");
  else if (i % 5 == 0)
    console.log("Buzz");
  else
    console.log(i);
}

BOOK

for (var n = 1; n <= 100; n++) {

 var output = "";

 if (n % 3 == 0)

   output += "Fizz";

 if (n % 5 == 0)

   output += "Buzz";

 console.log(output || n);

}
    • Chess Board
      • I feel like my solution is incredibly complex for something that should be much simpler. This also took me WAY too long to figure out and I’m pissed.
      • Of course theirs is way shorter. I completely forgot I could treat the board as a 2D array and just add up the x and y to get alternating values per row. God dammit.
      • After looking at their method I tried to do their solution from scratch again and it took me 60 seconds.

MINE

var output = "";

var height = 8;

var width = 8;

for (var row = 0; row < height; row++) {

 if (row % 2 == 0) {

   for(var n = 1; n <= width; n++) {

     if (n % 2 == 0)

       output += "#";

   else

       output += " ";

     if (n % width == 0)

       output += "\n";

   }

 }

 else {

   for (var n = 1; n <= width; n++) {

     if (n % 2 == 0)

       output += " ";

     else

       output += "#";

     if (n % width == 0)

       output += "\n";

   }

 }

}

console.log(output);

 

BOOK

var size = 8;

var board = "";

for (var y = 0; y < size; y++) {

 for (var x = 0; x < size; x++) {

   if ((x + y) % 2 == 0)

     board += " ";

   else

     board += "#";

 }

 board += "\n";

}

console.log(board);

October 03, 2016 🍅🍅🍅🍅🍅🍅🍅

  • JavaScript Road Trip: Part 2
    • Level 2
    • Level 3
  • Eloquent JS Chapter 3 - Functions
  • If this reads how I think it reads I may be in lucky with financial help. http://www.techopportunityfund.org/
    • The Tech Opportunity Fund is a partnership of organizations committed to increasing access to technology education for all. The Fund is designed to remove financial barriers for people who are underrepresented in the technology industry, including women and people of color. Students with financial need are encouraged to apply to receive a full-tuition scholarship to attend a full-time, immersive code school and take the first step toward a fulfilling career in technology.
    • Applications will open by January 2017.
    • Hopefully Hack Reactor will become a partner.
  • Bootcamp Job Placement Infographic Report
  • Why Cisco Hires Hack Reactor Alumni
  • Here's a list of 520+ free online programming/CS courses (MOOCs) with feedback(i.e. exams/homeworks/assignments) that you can start this month (October 2016)
  • Jobs in Atlanta: https://www.atlantastartupjobs.com/
  • Worked on putting all of my alumni network contacts into a Todoist project and one google doc for easier follow-up and tracking.
    • Need to think of a better way to organize all of these contacts that is easily sortable by who I’ve contact and who I haven’t. I will ponder this a little.
    • Also I want to email all of these people from my craigrodrigues.com email address so I will make sure that is up and running and throw it on Google Apps for email hosting.
    • I will also work on a template for each person, but tailor each to how I found them: if they have a blog or wrote about their experience or if they are part of a bootcamp itself (founder/teacher/employee).
  • Read 50 Proven Email Scripts by Ramit Sethi pages 1-
    • Most emails to busy people should have one simple purpose: To allow the busy person to reply and say, “Yes.” Nothing more.
    • Why Most Emails Get Overlooked
      • Confusing and vague with no CTA.
      • Busy people want to help do-ers, not talkers.
    • When emailing, if you want something from someone, you are lower-status.
      • A busy person can get along just fine if they ignore your email.
      • Treat writing emails as a skill. It’s something that you can work on and get better at.
    • The 5-Minute Straitjacket Technique

image02

🎉🎈 October 04, 2016 🎈🎉

🍅🍅🍅

October 05, 2016 🍅🍅🍅🍅

screenshot-2016-10-06-07-37-12

October 06, 2016 🍅x11

    • Frontend Masters: Javascript Basics
      • Variables and Blocks
      • Conditional Statements
      • Loops
      • Functions
      • Scope
      • Challenge #1
        • Before ES6 making a variable name ALL_CAPS means it should be treated as a constant.
        • I did a lot of “side effects” in my functions while he says you should try to keep functions to have as little impact to the outside world as possible so they should have been returning values instead of changing variables.
      • EcmaScript 6
    • Reading Clean Code Book
      • Foreword
      • Introduction
      • Chapter 1: Clean Code
        • What does a Code Review do and feel like? How does it work?
        • What is “Lean” and what is “Agile?”
      • Chapter 2: Meaningful Names
        • If a name requires a comment, then the name does not reveal its intent.
          • int d; // elapsed time in days
        • Can a name be too long?
        • A class name should not be a verb.
        • Methods should have verb or verb phrase names like postPayment, deletePage, or save.
        • I don’t know shit about objects and classes :(
      • Chapter 3: Functions
        • They should be small.
  • FUNCTIONS SHOULD DO ONE THING. THEY SHOULD DO IT WELL. THEY SHOULD DO IT ONLY.
        • The art of programming is, and has always been, the art of language design.
      • Chapter 4: Comments
  • So when you find yourself in a position where you need to write a comment, think it through and see whether there isn’t some way to turn the tables and express yourself in code. Every time you express yourself in code, you should pat yourself on the back. Every time you write a comment, you should grimace and feel the failure of your ability of expression.

October 07, 2016 🍅🍅

  • Eloquent Javascript Chapter 4
    • Tough chapter since I am unfamiliar with objects.
    • They are like structs.
    • Objects can also serve as maps, associating values with names. The in operator can be used to find out whether an object contains a property with a given name. The same keyword can also be used in a for loop
      • for (var name in object)
    • to loop over an object’s properties.
    • Exercise 1: The sum of a range
      • Nailed it first time.
    • Exercise 2: Reversing an array
  • Google Careers Technical Development Guide
  • The Technical Interview Cheat Sheet
  • Free JS books!

Learning to Code: Week 22 - Understanding The Weird Parts

Learning to Code: Week 20 - Picking Bootcamps