I tried to start learning basic Javascript in January but lost motivation when it got too hard to digest. I managed to get through 37% of the Codeacademy course.  So here I am back on Codeacademy.com which is a free interactive platform for learning the basics of various programming languages. My good friend Patrick told me about it and I just can’t believe it’s free.

I decided to give it another go as one of my work mates showed me this mobile game he had made… in his spare time! I just couldn’t believe it it was so sick. It just reminded me of how much time I use to spend just working on my own little projects as a kid on the WWW and how that hobby turned into a career. Without that passion and enjoyment I wouldn’t have learnt how to use the Adobe suite or basic HTML and got to where I am. Now I work in that field and I feel the flame has died and it’s become a chore. He kind of motivated me to just do shit for myself and continue learning for fun.  So here I am dying a little bit. I read somewhere that writing about your findings, struggles and what you have learnt helps you retain the knowledge so I’m going to start writing about how javascript is killing me softly with this stringggg. Just kidding 😛 I kind of like it even though it keeps fucking me up by not working it has solutions most of the time unlike art which is subjective.

At the moment I’m 50% through the course. I decided to re-start it from the beginning and I’m understanding it a lot more. I’ve started to learn about “switch” but the main thing I have been struggling with is a do while loop and what the purpose is.

My work mate has been so kind to sit down and talk me through it and give me a clip of code to work with to upgrade one of my Codeacademy tasks.  Apparently a while loop is similar to a for loop but I still don’t know what the difference between the 2 are so I need to research into that now and I’ll write my findings here as reference in my own terminology.

A loop is great if you want to execute the same code repeatedly using a different value. It turns a multi-lined code into shorter less repetitive code.

  • for – loops through a block of code a number of times
  • for/in – loops through the properties of an object
  • while – loops through a block of code while a specified condition is true
  • do/while – also loops through a block of code while a specified condition is true

A for loop executes a piece of known code a number of times. The advantage of using this is that we know how many times the loop will execute before the loop starts.

for (executed before starting; condition; starts after loop finishes executing) {
code to be executed each loop
}

A while loop loops through code if the condition is true. The variable needs to increase in the condition otherwise it will crash.

while (condition) {
    code to be executed
}

A do while loop will execute the action once before checking if the condition is true. It will then loop through and keep doing the action until the condition becomes false.

do {
    code to be executed
}
while (condition);

(source: w3schools)

A “For” Loop is used to repeat a specific block of code a known number of times. For example, if we want to check the grade of every student in the class, we loop from 1 to that number. When the number of times is not known before hand, we use a “While” loop.

(source: Utah)

 


 

Javascript Journey! by Tanya Brassie for inCahoots

Bexa

Bexa

An avid explorer, learner and adventure finder. My favourite thing about blogging is having a safe place to document and explore my thoughts, dreams and ideas. I love having deep chats, internetting, my job, art and design thingies, handcrafting, experiencing new things and learning more about people and the world we live in.

Leave a Reply