JavaScript Practice: Printing Even Numbers Between 1–50 Today’s JavaScript practice was all about applying conditional logic inside a loop — a very common real-world scenario in programming. Here’s the snippet I worked on 👇 for (let i = 0; i <= 50; i++) { if (i % 2 == 0) { console.log(i); } }; What’s happening here? for (let i = 0; i <= 50; i++) ➝ Starts at 0 and keeps looping up to 50. if (i % 2 == 0) ➝ The modulus operator (%) checks if the number divides evenly by 2. console.log(i) ➝ Prints only the even numbers. Why is this useful? This simple logic is the foundation of many real-world tasks: Filtering numbers Validating input Working with datasets Writing conditional operations in loops Understanding conditions inside loops helps strengthen logical thinking — an essential skill for problem-solving in JavaScript and beyond. Every small practice builds consistency, Every line of code builds logic, And consistency builds developers. Let’s keep learning and growing! #JavaScript #LearningJourney #CodingPractice #WebDevelopment #Tech #Programming
JavaScript Practice: Printing Even Numbers with Loops
More Relevant Posts
-
💡 Today’s JavaScript Learning Update Today, I dedicated my time to practicing and understanding JavaScript operators, one of the key building blocks of programming logic. My focus areas included: 🔹 Arithmetic Operators – I learned how to perform different mathematical calculations using symbols like +, -, *, /, and % to handle numeric operations efficiently. 🔹 Logical Operators – I explored how to use && (AND), || (OR), and ! (NOT) to create conditional statements and control the decision-making flow in a program. 🔹 String Concatenation – I practiced combining multiple strings using the + operator and template literals to create dynamic and meaningful outputs in web pages. This practice helped me gain a clearer understanding of how JavaScript performs computations, evaluates logic, and handles text. Every new concept I learn makes me more confident and creative in writing efficient and interactive web code. I’m excited to continue exploring JavaScript step by step and apply these concepts to build real-world projects. #JavaScript #WebDevelopment #LearningJourney #CodingPractice #FrontEndDevelopment #Programming #DevelopersCommunity #JavaScriptOperators #TechSkills #CodeNewbie
To view or add a comment, sign in
-
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
To view or add a comment, sign in
-
-
Just wrapped up a productive session tackling 9 fundamental JavaScript looping challenges! 🎯 From printing numbers forward (for loops) and backward (while loops) to generating even/odd series and calculating the sum of a range, these exercises are the building blocks of dynamic web development. I also dove into practical applications like creating multiplication tables and finding numbers divisible by both 3 and 5. It's amazing how much you can build once you master loops and basic control flow! If you're learning to code, I highly recommend starting with these types of foundational logic problems. I've pushed all the code and solutions to my GitHub for anyone who wants to review the functions (Q1 through Q9) and practice their logic. Feel free to check it out! 👇 Repository Link: https://lnkd.in/djWaxXV2 #JavaScript #WebDevelopment #CodingChallenge #Programming #Logic #LearningToCode #CodeLife Connect with me: GitHub: https://lnkd.in/d7zWUeDG X: https://lnkd.in/dn3yZDYY
To view or add a comment, sign in
-
✅ What is HTML? HTML stands for HyperText Markup Language. It is the standard language used to create and structure webpages. HTML is not a programming language — it is a markup language that tells the browser how to display content. 🧩 What does HTML do? It structures the content on a webpage, such as: Headings Paragraphs Images Links Lists Tables Forms 🔗 HTML + CSS + JavaScript HTML alone = structure CSS = style and colors JavaScript = interaction and behavior Together → complete web development #HTML #CODING #JAVASCRIPT #PYTHON #CSS #REACT
To view or add a comment, sign in
-
-
Topic: "Understanding JavaScript Operators" 📝 Post: Today I learned about JavaScript Operators — special symbols used to perform operations on values and variables. They help us do calculations, make comparisons, and control logic in our programs. Here are a few common types 👇 Arithmetic Operators – used for basic math operations let a = 10, b = 5; console.log(a + b); // 15 (Addition) console.log(a - b); // 5 (Subtraction) console.log(a * b); // 50 (Multiplication) Comparison Operators – used to compare two values console.log(a > b); // true console.log(a === b); // false Logical Operators – used to combine conditions console.log(a > 0 && b > 0); // true (AND) console.log(a > 0 || b < 0); // true (OR) console.log(!(a === b)); // true (NOT) Learning these helps write conditions and calculations easily in JavaScript! 🚀 #JavaScript #WebDevelopment #LearnToCode #FrontendDevelopment #ProgrammingBasics #CodingJourney #100DaysOfCode #TechLearning #DeveloperCommunity
To view or add a comment, sign in
-
💭 Is HTML Really a Programming Language? A friend told me he’s learning programming. They started with JavaScript, now they’re on HTML, and soon, CSS. I paused and thought: Wait… HTML? A programming language? 🤔 Personally, I don’t think so. HTML (HyperText Markup Language) simply defines the structure of a webpage — headings, paragraphs, images, links, all wrapped in tags. It tells the browser what to show, not how to think. A true programming language, in my view, should have: Data types (strings, numbers, booleans) Data structures (arrays, objects, etc.) Logic — loops, conditions, functions, classes HTML doesn’t do any of that. It’s powerful, yes, but it’s markup, not logic. Funny enough, when I looked it up later, opinions were split — some say it is, others say it’s not. What do you think? 👉 Is HTML a programming language or just the backbone of the web? #WebDevelopment #Programming #HTML #Coding #JavaScript #TechDiscussion
To view or add a comment, sign in
-
🟢 #Mastering #JavaScript #Arrays: #Essential #Methods You Should Know 📝If you work with JavaScript, arrays are your best friend. But knowing the right methods can make your code cleaner, faster, and much more readable. Here are some essentials: #push() – Add elements to the end of an array. #pop() – Remove the last element. #shift() – Remove the first element. #sort() – Arrange elements alphabetically or numerically. #indexOf() – Find the first index of an element, or -1 if it’s missing. #lastIndexOf() – Find the last index of an element. 💡 Knowing these can save your time and help to write more efficient, readable code. 🔔 Follow: Code Harvester for more Updates.🎯 ♻ Repost to help others find it. 💾Save this post for future reference. Document credit goes to the respective owner. #JavaScript #Array #UI #WebDevelopment #CodingTips #Programming #CodeHarvester #Developer #coding #programming #softwaredevelopment
To view or add a comment, sign in
-
Let me share some “Do’s and Don’ts” for functions in programming Function Do’s ========= 1.Give a clear name — makes code easy to understand Example: calculateTotal() instead of ct() 2.Use parameters instead of hardcoding values — reusable and flexible Example: .js function add(a, b) { return a + b; } 3.Keep it short and focused — each function should do one thing only Example: .cs bool IsAdult(int age) { return age >= 18; } 4.Add comments if needed — explain why something is done, not what 5.Return a result instead of printing directly — if possible Example: .js return result; Function Don’ts =========== 1.Don’t make functions too long or complex — hard to read, test, or debug 2.Don’t use unclear names — avoid names like f1(), data(), processStaff() 3.Don’t repeat the same code in multiple functions — write once, reuse everywhere 4.Don’t change global variables inside a function — causes unexpected bugs 5.Don’t forget to handle errors or invalid input — unclear return message Example : .js if (b === 0) return 'Error: divide by zero'; Summary : Keep functions simple, clear, and reusable. Avoid confusion, duplication, and hidden side effects. #C# , javascript
To view or add a comment, sign in
-
🚀Day 27 of Cohort2.0 Today's class was about introduction of Javascript with The OG Harsh Vandana Sharma at Sheryians Coding School I've learned: 1️⃣. <script> tag and how nd where to attache it. 2️⃣. types of variables (var, let, const) 3️⃣. alerts (for a popup), prompt (for user input), warn, error, consol.log(for Printing). 4️⃣. we saw some crazy examples of JS used in websites and also discussed the road map of how we're going to learn JavaScript for clear mindset and to be prepared for it. #responsiveness #responsivedesig #css #scss #html #Cohort2 #webdevelopment #Javascript
To view or add a comment, sign in
More from this author
Explore content categories
- Career
- Productivity
- Finance
- Soft Skills & Emotional Intelligence
- Project Management
- Education
- Technology
- Leadership
- Ecommerce
- User Experience
- Recruitment & HR
- Customer Experience
- Real Estate
- Marketing
- Sales
- Retail & Merchandising
- Science
- Supply Chain Management
- Future Of Work
- Consulting
- Writing
- Economics
- Artificial Intelligence
- Employee Experience
- Workplace Trends
- Fundraising
- Networking
- Corporate Social Responsibility
- Negotiation
- Communication
- Engineering
- Hospitality & Tourism
- Business Strategy
- Change Management
- Organizational Culture
- Design
- Innovation
- Event Planning
- Training & Development