That feel when it works the first time

There is some ridiculously satisfying feeling that occurs when the code you type decides it works with no errors the first time you try it out. Albeit, I’m writing some pretty n00b code; it still feels good man.

From the CodeAcademy JavaScript Course: object/array/loop stuff used to build the “list all contacts” function in an address book.

var bob = {
firstName: “Bob”,
lastName: “Jones”,
phoneNumber: “(650) 777-7777”,
email: “bob.jones@example.com”
};

var mary = {
firstName: “Mary”,
lastName: “Johnson”,
phoneNumber: “(650) 888-8888”,
email: “mary.johnson@example.com”
};

var contacts = [bob, mary];

function printPerson(person) {
console.log(person.firstName + ” ” + person.lastName);
}

var list = function() {
var contactsLength = contacts.length;
for (i=0; i<contactsLength; i++) {
printPerson(contacts[i]);
}
};

list();

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