🚀 𝐓𝐡𝐞 𝐉𝐚𝐯𝐚𝐒𝐜𝐫𝐢𝐩𝐭 𝐋𝐨𝐨𝐩𝐢𝐧𝐠 𝐆𝐮𝐢𝐝𝐞 𝐟𝐨𝐫: The classic. Best when you know exactly how many times you need to run. 𝐟𝐨𝐫...𝐨𝐟: Modern and clean. Perfect for iterating over values in an array or string. 𝐟𝐨𝐫...𝐢𝐧: Use this for objects. It iterates over the keys (properties). 𝐰𝐡𝐢𝐥𝐞: Best when the number of iterations is unknown and depends on a condition. 𝐟𝐨𝐫𝐄𝐚𝐜𝐡(): The functional approach for arrays. Great for readability, though you can't "break" out of it early. // 1. The Standard For Loop for (let i = 0; i < 5; i++) { console.log(`Index: ${i}`); } // 2. For...Of (Best for Arrays) const fruits = ['🍎', '🍌', '🍇']; for (const fruit of fruits) { console.log(fruit); } // 3. For...In (Best for Objects) const user = { name: 'Alex', role: 'Dev' }; for (const key in user) { console.log(`${key}: ${user[key]}`); } // 4. While Loop (Condition-based) let energy = 3; while (energy > 0) { console.log("Coding..."); energy--; } 💡 𝐏𝐫𝐨 𝐓𝐢𝐩: If you are dealing with large datasets and need to transform them, consider array methods like .map() or .filter()—they are often more expressive than a standard loop! Feel free to reach me out for any career mentoring Naveen .G.R|CareerByteCode #javascript #webdevelopment #codingtips #programming #frontend
JavaScript Looping Guide: For, For...Of, For...In, While
More Relevant Posts
-
🚦 𝐋𝐞𝐭’𝐬 𝐚𝐝𝐝 𝐬𝐨𝐦𝐞 𝐥𝐨𝐠𝐢𝐜 𝐭𝐨 𝐭𝐡𝐚𝐭 𝐜𝐨𝐝𝐞! I’m excited to share the 3rd blog of my "JavaScript Essentials 101" series. After covering variables, data types and operators, it's time to learn how to guide your code through different paths. This time, we are diving deep into 𝐂𝐨𝐧𝐭𝐫𝐨𝐥 𝐅𝐥𝐨𝐰: 𝐈𝐟, 𝐄𝐥𝐬𝐞, 𝐚𝐧𝐝 𝐒𝐰𝐢𝐭𝐜𝐡. In my blog post, I breakdown exactly how JavaScript processes logic, using beginner-friendly examples that actually make sense. 𝐇𝐞𝐫𝐞 𝐢𝐬 𝐰𝐡𝐚𝐭 𝐰𝐞 𝐜𝐨𝐯𝐞𝐫: ✅ 𝐓𝐡𝐞 "𝐓𝐫𝐚𝐟𝐟𝐢𝐜 𝐑𝐮𝐥𝐞𝐬" 𝐨𝐟 𝐂𝐨𝐝𝐞: A simplified definition of what control flow actually means. ✅ 𝐈𝐟, 𝐄𝐥𝐬𝐞, 𝐚𝐧𝐝 𝐭𝐡𝐞 𝐋𝐚𝐝𝐝𝐞𝐫: Master foundational decision-making (using conditions like checking voting age or grading marks). ✅ 𝐓𝐡𝐞 𝐒𝐰𝐢𝐭𝐜𝐡 𝐒𝐭𝐚𝐭𝐞𝐦𝐞𝐧𝐭: How to use multi-way branching for cleaner, more readable alternatives to long else if chains. ✅ 𝐓𝐡𝐞 𝐁𝐫𝐞𝐚𝐤𝐢𝐧𝐠 𝐏𝐨𝐢𝐧𝐭: Why the break keyword is crucial inside switch. ✅ 𝐓𝐡𝐞 𝐆𝐨𝐥𝐝𝐞𝐧 𝐑𝐮𝐥𝐞: A practical breakdown of exactly when to use switch vs. if-else. Mastering these conditional structures is what transforms a simple "coder" into an "application builder." Stop letting your code run sequentially and start making it intelligent! 𝐑𝐞𝐚𝐝 𝐭𝐡𝐞 𝐟𝐮𝐥𝐥, 𝐝𝐞𝐭𝐚𝐢𝐥𝐞𝐝 𝐠𝐮𝐢𝐝𝐞 𝐡𝐞𝐫𝐞: https://lnkd.in/ghpw9iPc Mentions: Hitesh Choudhary Piyush Garg Chai Aur Code Akash Kadlag Jay Kadlag Suraj Kumar Jha Nikhil Rathore #JavaScript #CodingTips #WebDevelopment #LearnToCode #Programming #CodeLogic #Hashnode #ChaiAurCode #ChaiCode
To view or add a comment, sign in
-
-
✍️ One syntax change. Massive readability improvement. I wrote a complete guide on Template Literals in JavaScript — and why every developer should stop using + for string building. What's covered: → The exact problems with traditional string concatenation → How backtick strings work and what ${} actually does → Embedding variables, expressions, ternaries, and function calls inline → Multi-line strings — write HTML, SQL, and logs the way they're meant to look → Real use cases: dynamic URLs, HTML generation, dynamic class names, logging → Tagged template literals — how styled-components and GraphQL's gql work under the hood Readability is not a nice-to-have. It's how you write code other people (and future you) can actually maintain. Read the full blog here 👇 🔗https://lnkd.in/gJJp2xut Check out my Hashnode profile 👇 🔗 https://lnkd.in/gAwxuryw #JavaScript #WebDevelopment #CleanCode #Programming #ES6 #piyushgarg #chaicode #hiteshchoudhary
To view or add a comment, sign in
-
-
Building on the basics of JavaScript, I’ve gained a solid understanding of how core components build a functional system. Writing code is the heart of this process, and seeing these concepts integrate is a major highlight of my learning. I have been practicing variable assignments using let, const, and var, while using typeof to identify different data types. I also learnt how to structure Control Flow through if/else statements, switch cases, and comparison operators. By using logical operators—specifically AND (&&) and OR (||)—along with strict equality (===), I can now set multiple rules for my code. I understand how to ensure that if a primary condition isn't met, the "else" logic applies correctly so the program follows a specific path. I also learnt how to use for loops combined with the .length property. This allows the code to automatically track the number of characters or items in a dataset. Instead of hard-coding values, I can now write dynamic code that adjusts to the data it receives. I am still working through the fundamentals, and I am excited to see how everything will work together once the foundation is complete! #JavaScript #WebDevelopment #CodingJourney #SoftwareEngineering #Techcrush #Frontend
To view or add a comment, sign in
-
-
Day 58 of #90DaysOfCode Today I built a personal portfolio website using Flask, integrating backend logic with a fully designed frontend template. The application renders an HTML template and serves static assets such as CSS, images, and JavaScript, creating a complete web experience powered by a Python backend. How the application works • Uses Flask to handle routing and server logic • Renders HTML templates using render_template • Serves static files including CSS, images, and scripts • Displays a responsive and structured portfolio layout Key concepts explored • Template rendering using Flask and Jinja • Project structuring with templates and static folders • Integrating frontend UI with backend frameworks • Building complete web applications using Python This project helped me understand how backend frameworks can power full web applications beyond APIs. GitHub Repository https://lnkd.in/gnMWPqsr #Python #Flask #WebDevelopment #FullStack #SoftwareEngineering #90DaysOfCode
To view or add a comment, sign in
-
🚀 𝐓𝐲𝐩𝐞𝐒𝐜𝐫𝐢𝐩𝐭 𝐒𝐞𝐫𝐢𝐞𝐬 — 𝐀𝐫𝐭𝐢𝐜𝐥𝐞 𝟎𝟐 𝙇𝙖𝙗𝙚𝙡𝙚𝙙 𝘽𝙤𝙭𝙚𝙨: 𝙐𝙣𝙙𝙚𝙧𝙨𝙩𝙖𝙣𝙙𝙞𝙣𝙜 𝙑𝙖𝙧𝙞𝙖𝙗𝙡𝙚𝙨 𝙖𝙣𝙙 𝘽𝙖𝙨𝙞𝙘 𝙏𝙮𝙥𝙚𝙨 𝙞𝙣 𝙏𝙮𝙥𝙚𝙎𝙘𝙧𝙞𝙥𝙩 𝐕𝐚𝐫𝐢𝐚𝐛𝐥𝐞𝐬 in programming are like boxes that store data. In real life, we use labels to easily identify what’s inside a box, right? Because if a box has a label, it’s easy to understand what’s inside. If it doesn’t, things get confusing. The same concept applies to programming. But in 𝐉𝐚𝐯𝐚𝐒𝐜𝐫𝐢𝐩𝐭, these boxes don’t have labels. So inside a single JavaScript variable, you can store: 👉 a 𝙣𝙪𝙢𝙗𝙚𝙧 👉 a 𝙨𝙩𝙧𝙞𝙣𝙜 👉 a 𝙗𝙤𝙤𝙡𝙚𝙖𝙣 This flexibility might seem useful… But it’s one of the main reasons behind 𝐫𝐮𝐧𝐭𝐢𝐦𝐞 𝐞𝐫𝐫𝐨𝐫𝐬. 💡 𝐓𝐲𝐩𝐞𝐒𝐜𝐫𝐢𝐩𝐭 solves this problem using 𝙩𝙮𝙥𝙚𝙨. It allows you to add labels to your variables: 👉 If you only need to store 𝙩𝙚𝙭𝙩 inside a variable, you can use the 𝙨𝙩𝙧𝙞𝙣𝙜 type. 👉 If you only need to store 𝙣𝙪𝙢𝙗𝙚𝙧𝙨 inside a variable, you can use the 𝙣𝙪𝙢𝙗𝙚𝙧 type. 👉 If you only need to store 𝙩𝙧𝙪𝙚/𝙛𝙖𝙡𝙨𝙚 inside a variable, you can use the 𝙗𝙤𝙤𝙡𝙚𝙖𝙣 type. By using these types: ✅ Your code becomes safer ✅ Bugs are reduced ✅ Developer experience improves In this article, I explain: 📦 What variables really are 🏷️ How type labels work in TypeScript 🧠 What Type Inference is ⚙️ The role of the TypeScript compiler 📖 Read the full article here: 👉 https://lnkd.in/g725SZP4 #TypeScript #JavaScript #WebDevelopment #Programming #LearningInPublic #SoftwareEngineering🚀
To view or add a comment, sign in
-
-
I built a static site generator...that corrupts your content.** Introducing **The Void SSG** — a full-stack blog engine with a Lovecraftian twist. You create sites, write markdown entries, and publish them. But here's the catch: your content gradually degrades with eldritch symbols the more you use it. Mention Cthulhu in a blog post? The system detects it and applies themed corruption. Different readers see different content based on their "sanity threshold." Navigation links get obfuscated or vanish entirely. The build process outputs ANSI-formatted narratives describing what happened to your content — like terminal horror fiction. It's a CMS where the content fights back. A cursed journal that rewrites itself. **The tech stack:** 🔹 Java 21 + Spring Boot 3.2 backend with virtual threads for async builds 🔹 React 19 + TypeScript + Vite frontend 🔹 Three.js WebGL fluid simulation for the UI background 🔹 Spring Shell CLI for terminal-based "rituals" 🔹 MySQL 8 + Flyway for persistence 🔹 Configurable entropy modes: Daily, User-Based, Cryptographic **Key features:** → Regex-based detection for 7 Lovecraftian entities with unique side effects → Viewer-aware navigation that deterministically hides or renames links per visitor → Narrative build logs styled as terminal stories → Full REST API + interactive CLI + React UI This was a fun exercise in combining software engineering with creative writing and worldbuilding. Sometimes the best way to learn a stack is to build something weird with it. Check it out on GitHub 👇 https://lnkd.in/gn-nG5rC #Java #SpringBoot #React #TypeScript #WebDev #SideProject #CreativeCoding #Lovecraft #OpenSource
To view or add a comment, sign in
-
-
🚀 Starting my 30 Days of JavaScript – Logical Thinking Series. Goal: Improve problem-solving skills by building one small project every day. Day 1: Rock Paper Scissors Game 🎮 Built using conditional logic and random value generation. Here code: let playGame = confirm("Shall we play rock, paper, or scissors?"); if (playGame) { //play let playerChoice = prompt("Please enter rock, paper, or scissors."); if (playerChoice) { let playerOne = playerChoice.trim().toLowerCase(); if ( playerOne === "rock" || playerOne === "paper" || playerOne === "scissors" ) { let computerChoice = Math.floor(Math.random() * 3 + 1); let computer = computerChoice === 1 ? "rock" : computerChoice === 2 ? "paper" : "scissors"; let result = playerOne === computer ? "Tie game!" : playerOne === "rock" && computer === "paper" ? `playerOne: ${playerOne}\nComputer: ${computer}\nComputer wins!` : playerOne === "paper" && computer === "scissors" ? `playerOne: ${playerOne}\nComputer: ${computer}\nComputer wins!` : playerOne === "scissors" && computer === "rock" ? `playerOne: ${playerOne}\nComputer: ${computer}\nComputer wins!` : `playerOne: ${playerOne}\nComputer: ${computer}\nplayerOne wins!`; alert(result); let playAgain = confirm("Play Again?"); playAgain ? location.reload() : alert("Ok, thanks for playing."); } else { alert("You didn't enter rock, paper, or scissors."); } } else { alert("I guess you changed your mind. Maybe next time."); } } else { alert("Ok, maybe next time."); } #JavaScript #WebDevelopment #LearningJourney #30DaysOfCode #Frontend
To view or add a comment, sign in
-
📦 Variables & Data Types Link : https://lnkd.in/gN7c82-T Most beginners jump straight into writing code without understanding how programs actually store information. So I started from the very beginning. In this chapter I cover: → What variables are (with a simple labelled-box analogy) → How to declare with var, let, and const → All 5 primitive data types — string, number, boolean, null, undefined → The key difference between var, let, and const → What scope means and why it matters Plus a 4-part assignment at the end to make everything stick. The rule I wish someone told me earlier: ✅ Default to const ✅ Switch to let only when the value needs to change ❌ Avoid var entirely in modern code If you're learning JavaScript or teaching someone who is — this is where the series starts. #JavaScript #WebDevelopment #LearnToCode #chaicode #Frontend #JSFundamentals #hiteshchoudhary #piyushgargh
To view or add a comment, sign in
-
-
Why is "Edit PDF" still a premium feature in 2026? I got tired of seeing "You've reached your limit of 3 free edits" every time I needed to fix a simple typo. So, I built the solution. Meet DocForge - a full-stack PDF suite that is truly unlimited. No "5 files per month" cap. No watermarks. No "Pro Plan" for basic text overlays. Building a tool that handles heavy PDF manipulation for free required a unique architectural approach. I couldn't rely on expensive third-party APIs, so I built a Hybrid Mono-Container system that runs two languages in one environment. The Tech Stack Frontend: React + TypeScript + Tailwind CSS. Backend: Node.js (Express), FastAPI(Python). Processing Engine: Python (FastAPI) + Ghostscript (System-level binaries for pro-grade compression). Authentication: Clerk (Secure, metadata-driven user management). Server Deployment: A custom Docker configuration running both services on a single Render node to keep overhead near zero. Features: Advanced Editor: Overlay text, change fonts, and "white-out" content. Pro Compression: Shrink files by up to 90% without losing text clarity. Merge : Combine multiple documents instantly. Pdf to Word : Convert Pdf to Word directly. I'm building this in public. Check out the code : GitHub: https://lnkd.in/giuSEpAB Live link: https://lnkd.in/g25rBqxd #BuildInPublic #OpenSource #SoftwareEngineering #ReactJS #NodeJS #Python #FastAPI #Docker #PDFEditor
To view or add a comment, sign in
-
🔥 **forEach() vs map() – What’s the Real Difference?** Many developers use them interchangeably… but they’re NOT the same! 👀 Let’s break it down 👇 🔶 **forEach()** ✅ Used for side effects ✅ No return value ✅ Can mutate the original array ❌ Not chainable 👉 Best for: * Logging * Updating the DOM * Calling APIs * Modifying external variables 🟢 **map()** ✅ Used for transformation ✅ Returns a NEW array ✅ Does NOT mutate original array ✅ Chainable ✅ Output array has same length 👉 Best for: * Transforming data * Formatting values * Creating a new array from existing data 💡 **Rule of Thumb:** If you need a new array → use `map()` If you just want to perform an action → use `forEach()` --- 🎯 Interview Question: What happens if you use `return` inside forEach()? Comment your answer below 👇 #JavaScript #WebDevelopment #Frontend #Coding #Developers #LearnToCode
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