loading...
Cover image for Finally Understanding JavaScript

Finally Understanding JavaScript

lynnecodes profile image Lynne ・2 min read

I can't tell you enough, how much I am starting to get JavaScript after four weeks of tutorials, reading, challenges, and games! This really was a learning experience for me. I had to figure out how my brain wanted information presented for it to stay put.

I got so excited when I finally understood how loops work with the help of Head First JavaScript Programming A Brain-Friendly Guide by Eric Freeman & Elisabeth Robson. If you are having trouble diving into Javascript (like I did), I highly recommend this book if you are a visual learner. There were pictures and arrows and browser examples. I never had been so excited to read a book and try out the exercises!

I even learned how to code Happy Birthday!

var name = "Joe";
var i = 0;

while (i < 2) {
  document.write("Happy Birthday to you.<br>);
  i = i + 1;
}

document.write("Happy Birthday dear " + name + ",</br>");
document.write("Happy Birthday to you. </br>;

I also learned what pseudocode is, which was very helpful to understand the outline of what's going on before you even insert the JavaScript code. It reminds me of the fifth grade when we would brainstorm our short stories--figuring out the beginning, what will happen in the middle, and how we get to the end. I don't know why I didn't think of writing out the logic first! It makes so much sense to visually see what codes are appropriate for each action.

My mind is blown. Functions, arguments, parameters, global and local variables . . . I'm quite enjoying JavaScript!

Last Week's Accomplishments:

  • Attacking JavaScript at a different angle

Check it out:

  • Books I've Started:
    • Head First JavaScript Programming A Brain-Friendly Guide by Eric Freeman & Elisabeth Robson

On My Mind:

  • Who out there is a visual learner? Do you have any tips for making learning code fun? Or understandable?

Until next week!
Alt Text

Posted on by:

lynnecodes profile

Lynne

@lynnecodes

Changing my career to change my life! Looking for a job in this super fun dev world!

Discussion

pic
Editor guide
 

I think you can do better with the birthday song. Why not use a loop to 4 instead of 2 and use an IF-THEN-ELSE construction to print the different line on the count of 3.....
Apart from that: happy coding :)

 

If-then-else? How about picking up another technique, the ternary operator?

while (i < 4) {
let message = (i ==3) ? "Happy Birthday dear " + name + "," : "Happy Birthday to you.
";
document.write(message);
i = i + 1;
}

Which isn't the end of ways to refactor this. You could get rid of the temporary variable by having the ternary inside the document.write(), and you could change the while loop to a for loop. There's almost never only one way to do something when it comes to programming.

 

This is great! Thanks for building on this code and showing me another way to write it! I'm learning so much.

 

Nice! I didn’t think of that! Thanks so much for pointing that out. That’s great advice and I’ll keep that in mind for improvement. 👍🏼

 

That feeling is what you need to be a programmer. I can tell you, after 30 years of programming, it never left me. As long as you follow your passion(s) and are not trapped with job requirements/clients you don't like but are forced to work on. Then its pure work.
That feeling is the most importsnt requirement. After that, you only need time (a fun time!). No degrees, no fancy hardware, no big companies.

 

That's exactly what I want! To not feel like I'm doing something that I'm forced to work on but actually enjoy. And I think I found it in programming. What I'm learning is getting very exciting!

 

Great work! I was in your position not too long ago. Still learning now.

I am also a visual learner and I really like puzzles. So, I spent a lot of time on Codewars, which helped expose me to loads of different methods. Though, it won't teach you anything about the DOM.

Keep us updated! :)

 

I really like puzzles too. I’ll check that out. It’s always great to see one problem many different ways. Thanks for the suggestion!

 

I am happy for you.

 

Thank you so much!

 

Head First books are sooo good. I highly recommend anyone to look through their line up for a book on a subject of interest. They're phenomenal at teaching.

 

It was a very good read! There were many times when I thought I wasn't going to get a concept and Head First just explained it so easily!

 

I’ll definitely be taking the time to read it! Thank you for sharing your article!

 

I got so excited when I finally understood how loops work

Sounds more like understanding programming in general than just understanding javascript. Good luck with your learning :D

 

It just felt like figuring one thing out was a gateway to understanding all that’s programming. Haha. What a rush! Thanks for the luck! My brain appreciates it!