My First “Program” Attempt

I finished Codecademy’s JavaScript track a couple of weeks ago, but haven’t yet had the chance to make a post, so here it goes. I’ve been busy and haven’t really done much programming since (aside from a little more dabbling with some additional JavaScript lessons on Codecademy’s site that aren’t part of the track). Since I was falling a bit off the programming wagon, I asked my husband what I should do next. He challenged me to make a dog management program in which I could program in dogs, add dogs, remove dogs, and search for dogs. Hmmm…well, seemed simple enough, but it had been a couple of weeks since I had really been doing much programming, so I was a bit nervous. However, never one to pass on a challenge, I figured I’d give it a go. Plus, I’m pretty sure Codecademy had prepared me enough for a simple program like this, so the next day I attempted my program.

Codecademy has a section where you can use their website to write programs (they have one for Python, Ruby, and JavaScript). I selected JavaScript and started programming away. It was pretty smooth sailing for the most part. I first created a Dog object, which included the properties name, breed, and age), so that I could easily create some sample dogs for my program. After making the object, I created a spikey variable and an echo variable (my two dog entries). I then created a var contacts array which included spikey and echo (obviously…). Since I wanted to be able to print out the names of my dogs, I then added a printDog function that would print to the console the dogs’ names. Next, I created a list function, so that I could quickly print out a list of my “dog contacts.”

Because my husband wanted me to be able to search for dogs, I then added a search function so that I could easily see if a particular dog was in my contacts. The next part of the program was adding an add function so that I could add dogs and then finishing off with a remove function so I could delete animals from my contacts (what can I say? Spikey and I have a tumultuous relationship… ūüėČ Just kidding.). ¬†The hardest part of the whole program was simply figuring out how to remove a contact, since Codecademy hadn’t gone over this in the tracks. ¬†Because I wasn’t entirely sure how to do this, I did what everyone does – I googled it. Once I had googled it, I quickly realized that I would have to use array.splice, which ended up being simple enough.

Now came the real test: seeing if I had passed the challenge presented to me by my husband. Sure, I¬†thought¬†I had completed the challenge correctly, but would the program¬†actually¬†work? ¬†Well, I decided to either sink or swim and called the hubby over to test it out. Sure enough, it worked! ūüôā Yay. Rock on for a beginning programmer. In retrospect, I know this is a truly¬†simple program, but having never programmed before in my life and only completing 2 weeks of recreational programming (about 1/2 an hour to an hour a day), I felt very proud of myself. ¬†So even though you may feel like banging your head against the wall, don’t…just keep on programming little grasshopper.

You can find my code below. Simple, I know, but good enough for me. ūüôā Now my husband wants me to make modifications to make it more complex….gulp.

Happy Programming!

 

function Dog(name, breed, age) { 
    this.name = name; 
    this.breed = breed; 
    this.age = age; 
    }

var spikey = new Dog("Spikey", "chihuahua", 7);
var echo = new Dog("Echo", "chihuahua", 2);
var contacts = [spikey, echo];

function printDog(dog) { 
    console.log(dog.name + " "); 
}

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

var search = function(name) {
    var contactsLength = contacts.length;
    for (var i = 0; i < contactsLength; i++) {
        if(name === contacts[i].name) {
            printDog(contacts[i]);
        }
        }
    };

 function add (name, breed, age) {
     contacts[contacts.length] = {
         name: name,
         breed: breed,
         age: age
     };
 }

function remove (name) {
    for (var i =0; i < contacts.length; i++)
   if (contacts[i].name === name) {
      console.log("Is this working?");
      contacts.splice(i,1);
   }
}

indapp

 

My Continued Exploration of JavaScript with Codecademy

Okay…I’m not even sure if I should be writing a blog post about JavaScript right now, but figured it’s been a while and my brain is completely fried from learning to code, so now’s a good a time as any.

When I first started Codecademy I was using Google Chrome, but periodically while I was coding, Chrome would suddenly crash and I’d lose all the progress I had made on a particular exercise and would have to start over. ¬†This brought me back to my high school information technology class (grade 9 perhaps?) where I had visions of throwing my large, old, stone-age desktop across the room for its continuous freezing and crashing capabilities. ¬†I can still remember what we were working on – typing up a good, ole letter to a fictitious company (yes, terribly exciting, I know). Technology was not my friend. Needless to say, a few crashes later, I decided to use Firefox instead which has since decreased any additional levels of anxiety and frustration (and the possibilities of my lovely old laptop going crashing across the room…I kid in jest of course).

Back to JavaScript…as I mentioned in my original post, I was using Codecademy to learn about it and was progressing through the 8 major sections that comprised the JavaScript track. ¬†I’ve been pummeling away at the courses and exercises and have now completed the 6 first major sections, which leaves 2 remaining. I’ve learned about the basics (i.e. strings, names, numbers, etc.), functions, for loops, while loops, control flow, and data structures. I’m currently working away at Objects I and am beginning to feel like a sinking ship. ¬†All the concepts and information are bubbling away in my brain, but they are also getting intermingled and a bit jumbled up (kind of like a jigsaw puzzle that fell onto the floor after you completed 3/4s of it). I imagine any of you who started learning to program with very little information technology background can relate. ¬†There are definitely times where I feel frustrated and want to just quit, but then there is the other part of me that seriously CANNOT wait until I am competent enough to actually start programming independently. ¬†I have visions of iPhone apps dancing in my head. ūüėČ Although I find programming to be frustrating and confusing at times, I am enjoying the challenge and the balancing act that it entails. ¬†I love it and hate it at the same time.

Codecademy itself has been a pretty good learning tool in my journey of programming awesomeness. ¬†Sometimes the courses overlap each other or leave out certain concepts that you’d think they should have mentioned or at least provided in the “hint” section. Different course instructors definitely have better capabilities of getting their information across to the “student” and you soon begin to look forward to certain instructor’s courses more so than others. ¬†I’m not necessarily saying that any of the instructors are poor; in fact, in general, they all seem to be very competent and effective in their instructions. ¬†But, as with anything, some seem to be more eloquent in their instructions than others. ¬†This should come as no surprise, though, as it is always the case regardless of the profession or situation.

Basically, what I guess I’m trying to say is that this journey is not going to be easy. ¬†If you, too, are learning to program you can probably relate and I just want you to know that, dude, you’re so not alone. ¬†I feel frustrated, excited, annoyed, and compelled all at the same time. We’re like kids learning how to ride bikes. ¬†We’re going to fall down, get scrapes, cry, have hissy fits and then get back onto the bike and try over. ¬†Before we know it, we’ll be riding without hands and plunging down mountains on crazy terrain. ¬†I’m in for the long haul and I hope you’ll continue to join me on my escapades.

Now that my brain is a jumble, I think it’s time to throw in some Focus T25 and work out that frustration. There’s something about exercise that just makes me feel so much better and zaps my worries away.

A Deeper Plunge Into JavaScript with Codecademy: The Beauty of the Switch

As I mentioned in a previous post, I have been exploring the world of programming starting with JavaScript via Codecademy. ¬†Today is my fifth day of learning and it seems to be pretty smooth sailing (albeit with some definite hiccups!). ¬†I haven’t been spending a huge amount of time each day, approximately around 1 hour per daily session. Thus far, I have explored the very basics (i.e. prompts, strings, numbers, console.log, etc.), functions, ‘for’ loops, ‘while’ loops, and if/else statements, to name a few.

As I was programming, I began to run into some forgetful moments. ¬†Yes, the hints on Codecademy are excellent and Google is a beaut, but I was starting to get a bit annoyed. ¬†There were times where I felt that the exercise I was being asked to do kind of skipped over some instructions (alternatively, this may simply have been because I had forgotten a previous task or simply wasn’t paying attention with the instructions or tips provided for the exercise). ¬†One particular annoyance occurred during my exploration into “while” loops. I went from the very simple programming of very basic while loops, to having to suddenly write a while loop that logs “I’m looping!” to the console three times without using console.log calls. ¬†Sure, for you programmer masterminds out there, a very simple task. For me, a pathetic beginner who feels a great achievement writing a VERY easy while loop, this was a very daunting task. ¬†The exercise had some of the loop previously written, but I became quite confused with empty brackets. I couldn’t recollect this being mentioned before, so I was at a bit of a standstill. ¬†I checked the Hint, but was still confused. I ended up calling upon my husband for some back up (and yes, he did look at me as if he was trying to instruct a small child…). ¬†Needless to say, I figured out how to do the task. ¬†Afterwards, I decided that perhaps part of my difficulty was that I kept forgetting what I had learned previously. I then decided to quickly go back and review the courses (which I LOVE about Codecademy). As I reviewed the previous courses and exercises, I began to jot down little reminder notes. ¬†Doing the process a second time and now having notes to refer back to is immensely useful. As I have proceeded into more lessons, I can now quickly look up a note I did and be able to complete the activity more easily.

Enough of my complaining, however! ¬†There was one thing that I did today that I absolutely loved (and I’m not entirely sure why…): the switch statement! ¬†The switch statement basically allows you to design a specific number of options (called case(s)), and then check a variable or expression against them to see if there is a match. ¬†If it matches, the program performs a specific action that you have specified. ¬†If it doesn’t match, then you execute a default option specified by you. We had a series of exercises introducing and reinforcing the switch statement. ¬†It was probably the easiest and quickest thing I have picked up on thus far (aside from the basics, like console.log and prompts). ¬†Codecademy broke the switch statement into chunks, having you first complete a small part, then adding on until you have to make your own, which for whatever reason, I found immensely entertaining. ¬†So…I guess what I’m saying is if you are finding yourself frustrated with the if/else or for loops or while loops while learning JavaScript, take a breather and look up the switch statement. Play around and have fun with it. ¬†Make yourself giggle. ¬†I sure did… ūüėČ

Below is a … um … G version of a switch I wrote. He he.

switch

 

Happy programming!

Intro to JavaScript

My Intro to JavaScript

My first foray into programming began with (queue ominous sounding music) JavaScript! ¬†With my husband’s suggestion, I decided to start learning programming with the assistance of the FREE (gotta love it) Codecademy website. I’ve just started exploring Codecademy, but am loving what I’m seeing so far. ¬†After you sign-up, they bring you to a “Learn” page that outlines different “Tracks,” which are “series of¬†courses grouped to help you master a topic or language” (http://Codecademy.com/learn). ¬†They provide a variety of tracks, including¬†Web Fundamentals,¬†JavaScript,¬†jQuery,¬†Python,¬†Ruby, and others. ¬†Codecademy provides a brief synopsis of what each programming track entails and what it does, which provides a quick and easy snapshot. Marty suggested I start with JavaScript, so I clicked away and, voila, began programming.

Once I selected JavaScript, I was brought to a page that breaks down the learning into a series of major topics and exercises (courses as they refer to them).  The JavaScript page was broken down into 8 major sections with each of those sections separated into separate courses (see photo).

javascript

¬†I began with the “Introduction to JavaScript” series and found each of the exercises easy to follow and quick to pick up on. One aspect that I really enjoy about Codecademy is that they provide a brief description of what you are about to learn followed by basic instructions to complete each “exercise” (see photo).

javascript2

If you get stuck on an exercise, most exercises have a little “Hint” section which you can click on for more advice, tips, and tricks.

hint

The very beginning basics of JavaScript seemed pretty easy to follow and apply, which was nice. ¬†I liked that Codecademy broke down what you were learning to make it manageable and allowed for success. ¬†As you complete exercises and tasks, you earn points and badges, which adds a little “oomph” to the whole process (Yay, gold star for me). It is also designed so that you are making games right away (you start with a very basic “Choose Your own Adventure” game), which always makes things a little more fun. They also encourage you to make your own. The intro was definitely useful, interesting and informative.

The second section for JavaScript, called “Functions,” was a bit more difficult. I tried this section on a different day and found that I sometimes forgot what I had learned prior to this. ¬†However, the website provides little hints and a Google search is easy to use, so again, the design of the website really aids in your success (and simply the luxury of the World Wide Web). ¬†If I got really stuck, I (luckily) could easily just ask my husband or you can always go back and “review” past exercises. I have a feeling that by the time I complete all 8 sections, that what I learned in the beginning will be cemented securely in my brain through the sheer repetition of the exercises. ¬†Because I am just learning the language right now, some things that seem tricky will become easier and ingrained in my memory (i.e. remembering what parentheses to use and when to use them).

I have definitely been enjoying my first exploration into programming, although there were definitely a few grumblings here and there (grrr….parentheses!).

If you are looking to start learning to program for fun, I definitely recommend checking out Codecademy. Not only is it super fun and easy to use, but it’s free, and nothing gets much better than that!

 

 

Adventures in Fitness and Programming

Welcome to my new adventures in fitness and programming! ūüôā ¬†I invite you to join me in my journey of exploration, which I’m sure will be coupled with both elation and frustration.

Why Fitness AND Programming?

As I grow older (approaching the big 3-0), I’ve decided to pursue new interests and passions. ¬†I’ve always enjoyed fitness, but have never been an “athlete” or in amazing shape. I grew up playing a whole bunch of different sports (ringette, hockey, soccer, basketball, etc.), but was never the “star.” ¬†Genetics and environmental factors have not been good to me. As such, I have decided that I want to focus more on my overall health, which of course includes fitness. ¬†As someone who is super busy (in reality, who¬†isn’t super busy?), I am going to explore easy ways to incorporate fitness and healthy eating into my daily routines so that I can achieve my healthy living goals. I don’t necessarily have anything specific in mind, but want to simply be a healthier, more improved version of myself.

As part of my journey to healthy living, I will be posting reviews of workouts that I am incorporating or have tried before. In addition, I will post reviews of any products or supplements that I am using or have used.  These will be blatantly honest reviews. I want to share my journey in hopes that my experiences (both successes and failures) help inspire others to achieve their goals.

So…why programming? ¬†Well, my husband is a programmer (he’s a genius at what he does, but don’t tell him¬†I said that…), so I always thought it would be interesting to learn a bit more about what he does on a computer all day long.¬†Couple that with the fact that I have always been interested in math and science, and it seemed like a great topic to explore. My husband makes iPhone apps as a hobby and I thought it would be fun to make some as well. However, before I can even attempt to do that, I need to learn the basics of programming. My husband has pointed me in the direction of Codecademy, which will be my starting point into the land of programming. Throughout my programming journey, I will also provide updates on my learning and experiences. Again, I hope others can learn and grow from my experiences and perhaps inspire me to keep going.

That is all for now.  I hope you enjoy my posts and if you ever have any questions or comments, please feel free to share!

PS – if you want to visit my husband’s blog, go here. ¬†He shares about iOS development and programming in general. You can also learn about the iPhone apps that he has developed.