Looping the Loop

Feb 9…Didn’t get home from work until 7pm so you can imagine my excitement about coding after a long day.  Thankfully, 30 minutes isn’t that long so it’s easier to just get it in vs complain about it (warm up for next month’s goal of not complaining about anything for 31 days).  I logged onto codecademy and all of the sudden $hit got real.  Why are they using <p> and </p> in lines of code now?  Why are they teaching me lessons called “looping the loop” when I barely remember how to do a loop?  Turns out, the <p> nonsense means paragraph in html, you know, that other programming language I don’t know but apparently need to know on some surfacy level….similar to my ability to speak Spanish.  Knowing <p> I guess is equivalent to my “hola, me llamo Brooke.”  I am actually selling myself short a little bit because I did manage to get through a few screens sans the “hint” button.  I even problem solved (secret code for “forgot to add a quotation mark and semicolon but realized later and fixed it”) on some of my lines of code that kept giving me an error.  Apparently, by the time you make it to loops, codecademy starts having a sense of humor.   It said in bold print “avoid infinite loops like the plaque.”  I don’t know how to create an infinite loop and I’m pretty sure I already forget how to create a regular loop, but the bold text made me scared – in addition to the special notes about having to refresh if you create an infinite loop which is the only way to make it stop.  All I could think about was the infinite loop I got stuck in when Chris synced our lights with our alarm at home last year.  I couldn’t get out of this loop of setting the alarm, opening the door, lights coming on, shutting the door to turn the lights off, then re-setting the alarm, opening the door, lights coming on, shutting the door to turn the lights off, etc.  Codecademy was also very funny tonight when it told me to make up my own line of code and it said “The beauty of programming is that you can do whatever you want!”  Um, okay.  I’m pretty sure if I don’t follow your rules exactly, codecademy (insert pointer finger and head swirl), then you won’t give me the outputs I’m looking for.  After the loops, or looping the loops, or whatever, I decided I wasn’t focused enough to finish out my last 10 minutes so I decided to do a little code research instead.  I found out that 75% of websites are created using PHP.  In a previous post I mentioned that Facebook was created using PHP, but so was WordPress (the site used for this very blog) so when I actually write code as the title of my blog it will interpret it as real PHP – so I have to dummy it down for all of you non-coders out there who read this thing. Ha!  I also learned that Girls Who Code is an actual organization.  It’s a nonprofit focused on closing the gender gap in technology and engineering.  They have summer programs for girls which you can sign up for right after you read the homepage stats that say only 12% of computer science grads are women.  I didn’t think that learning to code would really snowball into my personal campaign for girls in technology, though I do love the overusage of the hashtag #girlswhocode, but everyday (all 9 of them) my eyes are open now.  Today I was interviewing someone at work and when I asked about her interests she said that she loves data and analytics but ended her sentence by saying “but I’m not a data scientist guy.” Guy?  ::sigh::

Feb 10…Didn’t get home until almost 9:30pm tonight.  I should nix the #girlswhocode brand and move to #codingafterdark.  I left work around 6:15pm and headed over to an informational session for an organization that supports teen moms (reference my Tedx Columbus talk on “Raising Teen Parents” that I’m still waiting to go viral and take me to Hollywood, Oprah, book deals, and beyond).  The session ran over by 45 minutes so I got home way later than expected.  I know personally, there’s nothing more I want to do at 10pm than write a little PHP.  I couldn’t even pretend to have the energy to do this full blown laptop style so I spent 30 minutes on the iPad codecademy app.  The main difference between laptop and iPad is that on the laptop you actually have to write the code, on the iPad app you’re more-so selecting out of multiple choice the things that need to be inserted into the lines of code.  I am certainly not too advanced for the app but it’s not as challenging as when I practice on my laptop…though it does teach me better basics.  The main thing I learned this night is !== which basically means “not equal to.”

Feb 11….Another late night at work.  January’s blog highlighted the number of days I didn’t feel well – I guess February’s exists to highlight the number of hours I put into work.  I decided I needed to go back to writing the code myself on my laptop.  When I logged into codecademy my little thermometer of completion shows me I’m at 46% completion.  Not too shabby after 11 days.  Is it possible I will run out of lessons?  Or is that just 46% complete on one of many sessions?  I guess we’ll have to stay tuned?  So it throws me in where I left off on Monday…..loops.  Ugh, this is an infinite loop in itself…again.  I decide to go back a couple screens and while I was saying outloud “what the heck is looping a loop?!” Chris decides to help me out.  For some reason when he says in English what the code is saying, it works so much better in my brain!  I’m an audible learner vs a visual one.  Speak it to me and I’ll get it.  Show it to me and….eh.  So while I didn’t progress past the looping of loops per se, he talked me through the code that tells it (whatever “it” is) to keep flipping a coin until you get 3 heads in a row.  That’s an example of a loop (pics below).  Instead of writing hundreds of lines of code to tell it to keep flipping, you can write code that will loop until you’ve hit what you’re looking for – which in this case was 3 heads in a row.  I also learned that ++ actually means +1.  Chris claims it’s a faster way to code, or tell it to do something, or whatever, but I’m not sure I can measure time savings of hitting the + key over the 1 key, but I’m sure it’s helpful on some level?  We also recapped my learning  of !== which I previously said meant “not equal to.”  It’s actually not that easy.  != means “not equal to” when comparing contents, !== means “not equal to” when comparing contents plus type, and <> also means “not equal to” but I have no idea under what circumstance.  So Chris showed me examples of where you use double equal signs and where you don’t.  He kept me intrigued by showing me examples of when it’s true or false that “Brooke” = “brooke.”  After 11 days of coding, I’ve realized that coding is difficult and requires patience….but writing about coding is a challenge of it’s own.

Here are a couple examples of loops including the coin flip.

Loops2 Loops