DEV Community

Cover image for #javascript #apnacollege #webdev #beginners
Ali Hamza
Ali Hamza

Posted on

#javascript #apnacollege #webdev #beginners

Hello Dev Community! 👋

It is officially Day 11 of my journey to master the MERN stack! Today, I dived into Lecture 3 of Apna College's JavaScript playlist with Shradha Didi, focusing on one of the most powerful concepts in programming: Loops.

Before today, if I wanted to run a line of code 10 times, I had to copy-paste it. Today, I learned how to automate repetition efficiently.


🧠 Key Learnings From JS Lecture 3 (Loops)

I explored how JavaScript handles repetitive tasks using different types of loops, depending on the scenario:

1. The Classic Loops

  • for Loop: The absolute standard when you know exactly how many times the code needs to run. (e.g., executing a block exactly 5 times).
  • while Loop: Perfect when you want the code to keep running as long as a specific condition remains true.
  • do-while Loop: A unique loop that is guaranteed to run at least once, even if the condition is false from the start, because the condition is checked at the very end.

2. Modern JavaScript Loops (The Game Changers)

Shradha Didi also introduced two modern and highly useful loops that senior devs use all the time:

  • for-of Loop: Used exclusively for iterating over characters in a string or items in an array. It makes the syntax incredibly clean.
  • for-in Loop: Perfect for stepping through the properties of a JavaScript object.

🛠️ What I Actually Code / Practiced

I spent my practice session solving the practice problems from the lecture to lock in the logic:

  • The Even Number Challenge: Wrote a for loop that prints all even numbers from 1 to 100.
  • The Guessing Game: Created a simple mini-game using a while loop that keeps prompting the user to guess a correct "game number" until they enter the right answer.

Seeing the loop dynamically handle user input without breaking the browser console felt like a massive milestone!


🎯 My Goal for Tomorrow (Day 12 / Lecture 3 Part 2)

Tomorrow, I will be wrapping up the rest of Lecture 3 from Apna College:

  • Diving deep into Strings and their built-in methods (like .toUpperCase(), .trim(), and .slice()).
  • Learning how to manipulate text data dynamically.

💬 Let's Connect!

To the Apna College alumni: How long did it take you to crack the guessing game logic? To seniors: Do you find yourself using for-of loops more often than traditional for loops in production?

My Lecture 3 loop scripts are pushed to GitHub!
[Links in the Comments]

Keep learning, keep building! 🚀

Top comments (0)