JS challenge I solved today, Alhamdulillah: The Problem Write a panic() function that: i. Converts a sentence to uppercase ii. Adds ! at the end iii. Inserts a separator between words if it has more than one word My Thought Process I planned to: Split the string into words using split() Check if it has one word or multiple Use a normal space for single-word input Use a custom separator for multi-word input Then uppercase everything and add '!' The Mistake I initially made the logic more complex than necessary. The only thing that really changes is the separator. Clean Solution although different from the solution given by the teacher: What Clicked: Many problems feel big until you isolate the one part that actually changes. #javascript #frontend #learninginpublic #codingjourney
Panic Function in JavaScript
More Relevant Posts
-
🚀 Day 963 of #1000DaysOfCode ✨ Difference Between var, let & const in JavaScript These three look similar… but behave very differently in real-world code. In today’s post, I’ve broken down the differences between `var`, `let`, and `const` in a simple and practical way, so you can understand when and why to use each of them. From scope and hoisting to re-declaration and mutability, these concepts directly impact how your code behaves — and are often the reason behind many unexpected bugs. I’ve also explained common mistakes developers make while using them, so you can avoid those pitfalls in your own projects. If you’re writing modern JavaScript, having clarity on this is absolutely essential. 👇 Which one do you use the most — `var`, `let`, or `const`? #Day963 #learningoftheday #1000daysofcodingchallenge #FrontendDevelopment #WebDevelopment #JavaScript #React #CodingCommunity #JSBasics
To view or add a comment, sign in
-
Day 4 — Today was the day the web stopped being static for me. DOM manipulation. Sounds scary. Actually really fun. Built a simple to-do list from scratch — no libraries, no frameworks. Just vanilla JS touching the page directly. The moment I typed something in an input field and saw it appear on screen because of code I wrote... that feeling doesn't get old. Key thing I learned: event delegation. Instead of adding an event listener to every single element, you add one to the parent and let events bubble up. Cleaner and way more efficient. Also — preventDefault() is your best friend in form handling. Took me an embarrassing number of refreshing pages to learn that lesson. What was your first "I built this" moment in coding? #javascript #webdev #frontenddeveloper #learninpublic
To view or add a comment, sign in
-
-
Confused between var, let, and const? Here's all you need to know. 👇 Most JavaScript developers use all three — but few know exactly when and why. Here's a quick breakdown: ⚠️ var → Function-scoped, hoists as undefined, can be re-declared. Avoid it in modern code. 🔁 let → Block-scoped, re-assignable. Use it when values change. 🔒 const → Block-scoped, immutable binding. Your default choice. 💡 TDZ (Temporal Dead Zone) — let and const are hoisted but can't be accessed before their declaration line. That's a feature, not a bug. 💥One rule of thumb: Always start with const. Switch to let only when you need to reassign. Never touch var. Save this for your next code review. 🔖 #JavaScript #WebDevelopment #Frontend #JS #Programming #100DaysOfCode #CodeTips #SoftwareEngineering
To view or add a comment, sign in
-
-
Most JS developers use closures daily without knowing it. counter() finished running, but increment still remembers count. That's a closure. How does it remember? When a function is created in JavaScript, it doesn't just save the code — it also saves a reference to the variables around it at that moment. So even after the outer function is gone, that reference stays alive in memory as long as the inner function exists. Think of it like this the inner function carries a backpack of its outer variables wherever it goes. 🎒 You already use this in React's useState, debounce, and event handlers. Once I understood this, my React bugs started making sense. 🙂 Did closures confuse you at first? Drop a comment 👇 #JavaScript #MERN #WebDevelopment #LearningInPublic
To view or add a comment, sign in
-
-
🎨 I got tired of recoloring SVGs one at a time. You know that thing where you need 30 icons in a new brand color and you're sitting there doing find-and-replace on hex codes file by file? I kept doing that for way too long before I thought, okay, I should just automate this. So I built SVG Batch Recolor Tool. Here's how it works: 📋 Paste a bunch of SVG URLs 🎯 Pick a hex color ⚡ Hit recolor — all fills, strokes, and inline styles update instantly 👀 Live preview grid so you see what you're getting 📦 Download individually or grab everything as a ZIP It fetches the SVGs server-side (because CORS will ruin your afternoon otherwise), does the recoloring client-side with regex, and bundles the output with jszip. 🛠 Built with: Next.js 15 · React 19 · Tailwind v4 Honestly it's a simple tool. I just couldn't find one that worked the way I wanted, so here we are. The whole thing is open source 👇 🔗 Link: https://lnkd.in/gK-QQwi7 ♻️ Repost if this could save someone's afternoon. #webdev #nextjs #react #opensource #svg #developertools #frontend #javascript #typescript
To view or add a comment, sign in
-
-
A method easier than "methods"? 🤯 I was recently working on a problem where I needed to trim an array. I started writing a standard for loop to shift elements and was ready to reach for splice()... but then I tried an experiment. I simply wrote: arr.length = arr.length - 1 It worked perfectly. No methods, no complicated logic, just a direct property change. I actually thought I had found a bug! But after checking the MDN documentation, I realized this is a well-known, intentional feature of JavaScript. Why this is easier than splice() or pop(): Zero Complexity: You don't need to remember arguments or return values. Instant Truncation: If you want to keep only the first 3 items, just set .length = 3. Done. Performance: It's a high-speed way to discard elements without the overhead of method calls. Do you think you'll start using this as your default way to shorten arrays now, or will you stick to splice for better code readability? comment below .. #javascript #codingtips #frontend #react #webdevelopment #programming #webdev #softwareengineering Nikhil Kilivayil Brototype
To view or add a comment, sign in
-
-
🧠 Day 5 of 21days challenge JavaScript Higher Order Functions (HOF) 🔥 function greet(name) { ... } Why return a function? A higher-order function is a function that takes another function as an argument or returns a function. It helps write more reusable and flexible code. For easy understanding : HOF = function using another function Can take function as input Or return function as output 👉 That’s how powerful abstractions are built This changed how I write functions 🚀 #JavaScript #HOF #Frontend
To view or add a comment, sign in
-
-
PEP TASK-7 🚀 Built a Digital Clock using JavaScript I created a real-time clock application using pure JavaScript, focusing on how time-based functions work behind the scenes. 🔹 What this project demonstrates: • Real-time clock updates using setInterval() • Fetching current time with the JavaScript Date object • Formatting time (HH:MM:SS) dynamically • DOM manipulation to update UI instantly JavaScript makes it possible to build live, interactive features like clocks by continuously updating values every second using functions like setInterval() (Stack Overflow) This project helped me understand how real-time applications work and improved my skills in handling dynamic data in the browser. 💻 Check out the project here: 👉 https://lnkd.in/gWm4YYA5 Would love your feedback! 🙌 #JavaScript #WebDevelopment #Frontend #Coding #StudentDeveloper #Projects #LearningJourney
To view or add a comment, sign in
-
-
🔁 Understanding the forEach() loop in JavaScript The forEach() method is a simple way to iterate over arrays and perform an action for each element. 👉 Syntax: array.forEach((item, index) => { // logic here }); 👉 Example: const numbers = [1, 2, 3, 4]; numbers.forEach((num, index) => { console.log(`Index: ${index}, Value: ${num}`); }); 💡 Key Points: ✔️ Executes a function for each array element ✔️ Does not return a new array ✔️ Cannot break or use return to stop the loop If you need a return value, consider using map() instead. Small concepts like this build a strong JavaScript foundation 🚀 #JavaScript #WebDevelopment #Frontend #Coding #LearnToCode
To view or add a comment, sign in
-
What will happen if you call a variable before initialization? 🤔 That is called Hoisting 👉 "JavaScript moves declarations to the top of their scope before execution" Sounds confusing? Let’s break it down 👇 When you create variables or functions, JavaScript runs your code in 2 phases: 1️⃣ Memory Creation Phase Before execution, JavaScript scans your code and allocates memory Example (mentally): var a → undefined let b → uninitialized (Temporal Dead Zone) 2️⃣ Execution Phase Now JavaScript runs your code line by line 👉 If you access variables before initialization: var → returns undefined let / const → ReferenceError Why does this happen? Because: var is initialized with undefined in memory let and const are hoisted but stay in the Temporal Dead Zone (TDZ) until the line where they are declared Simple way to remember: var => “exist, but don’t have a value yet” let / const => “Don’t touch before declaration” ⚡ Bonus: Function declarations are fully hoisted, so you can call them before defining them Curious how functions behave in hoisting? 🤔 Go Google function vs function expression in JavaScript — it’ll surprise you 👀 That’s hoisting in JavaScript 🚀 #javascript #webdevelopment #coding #frontend #learninpublic #hoisting
To view or add a comment, sign in
-
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