DEV Community

Cover image for Finally Understanding JavaScript
Lynne
Lynne

Posted on

Finally Understanding JavaScript

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>;
Enter fullscreen mode Exit fullscreen mode

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

Top comments (17)

Collapse
 
patricktingen profile image
Patrick Tingen

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 :)

Collapse
 
ericgeek profile image
EricGeek

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.

Collapse
 
lynnecodes profile image
Lynne

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

Collapse
 
lynnecodes profile image
Lynne

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. 👍🏼

Collapse
 
pandaquests profile image
Panda Quests

No one understands JavaScript:
res.cloudinary.com/practicaldev/im...

Collapse
 
lynnecodes profile image
Lynne

Haha. You’re absolutely right!!

Collapse
 
psiho profile image
Mirko Vukušić • Edited

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.

Collapse
 
lynnecodes profile image
Lynne

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!

Collapse
 
aissshah profile image
aishah

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! :)

Collapse
 
lynnecodes profile image
Lynne

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!

Collapse
 
lynnecodes profile image
Lynne

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

Collapse
 
darkwiiplayer profile image
𒎏Wii 🏳️‍⚧️

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

Collapse
 
lynnecodes profile image
Lynne

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!

Collapse
 
bias profile image
Tobias Nickel

I am happy for you.

Collapse
 
lynnecodes profile image
Lynne

Thank you so much!

Collapse
 
robinsond7691 profile image
Robinson

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.

Collapse
 
lynnecodes profile image
Lynne

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!