How to Print Numbers from 1 to 100 with JavaScript Loops

JavaScript Basics: Printing Numbers from 1 to 100 Using a for Loop Learning to code isn't just about memorizing syntax — it's about understanding how logic works. One of the simplest yet most powerful concepts in programming is the loop, and today I practiced that using a small JavaScript snippet. What does this code do? It prints the numbers from 1 to 100 in the console. for (let i = 1; i <= 100; i++) { console.log(i); } Breakdown: let i = 1; → starts the loop at 1 i <= 100; → keeps running the loop until 100 i++ → increases the value of i by 1 each time This tiny piece of code shows how we can instruct the computer to repeat tasks efficiently — no need to write console.log() a hundred times manually! Why is this important? Understanding loops is a foundational skill in JavaScript (and all programming languages). Once you master loops, you'll be able to: Iterate through arrays Automate repetitive tasks Work with APIs and data sets Build dynamic logic in real-world applications Every big project starts with small steps like this. If you're also learning JavaScript, keep practicing — consistency is key. Let’s grow together! 💻✨ #JavaScript #Programming #WebDevelopment #LearnToCode #CodingJourney #Tech

  • text

To view or add a comment, sign in

Explore content categories