Today I practiced reversing a string in two different ways: ✅ Using a loop (logic-based approach) ✅ Using built-in JavaScript methods Manual Logic Version: let reversed = ""; let str = "hello"; for (let i = str.length - 1; i >= 0; i--) { reversed += str[i]; } console.log(reversed); Built-in Method Version: let reverseValue = "Javascript"; let res = reverseValue.split("").reverse().join(""); console.log(res); I'm focusing on improving my problem-solving skills to become job-ready as a Frontend Developer 💻 Github: https://lnkd.in/gxGSn-WS #javascript #frontenddeveloper #100DaysOfCode #webdevelopment #learning
Reversing Strings in JavaScript: Loop vs Built-in Methods
More Relevant Posts
-
JavaScript Practice – Reverse a String Today I practiced a simple JavaScript program to reverse a string. Question: Write a function to reverse a string. Code: function reverseString(str){ return str.split("").reverse().join(""); } console.log(reverseString("mary")); Output: yram Explanation: • split("") – Converts the string into an array • reverse() – Reverses the array elements • join("") – Converts the array back into a string I am currently learning Frontend Development and practicing JavaScript programs daily. #javascript #frontenddeveloper #codingpractice #webdevelopment #learning
To view or add a comment, sign in
-
-
JavaScript Practice – Find Even Numbers Today I practiced a simple JavaScript program to find even numbers from an array. Question: Write a function to find even numbers from an array. Code: function evenNumbers(arr){ return arr.filter(function(num){ return num % 2 === 0; }); } console.log(evenNumbers([1,2,3,4,5,6])); Output: [2,4,6] Explanation: • filter() – Creates a new array based on a condition • num % 2 === 0 – Checks if the number is even • Returns only even numbers from the array I am currently learning Frontend Development and practicing JavaScript programs daily. #javascript #frontenddeveloper #codingpractice #webdevelopment #learning
To view or add a comment, sign in
-
-
The JavaScript "this" Trap 🪤🔥 The Puzzle: What is the output? 🤔 const obj = { name: "JS", getName() { console.log(this.name); } }; const fn = obj.getName; fn(); Output: undefined Why? 🧠 In JavaScript, this depends on HOW a function is called, not where it is written. Lost Context: const fn = obj.getName only copies the function reference. Standalone Call: When you call fn(), there is no object (no dot) before the function. Global Context: It now runs in the Global Context (window object). Since window.name is not "JS", it returns undefined. How to Fix? 🛠️ ✅ Use .bind(): const fn = obj.getName.bind(obj); ✅ Use .call(): fn.call(obj); ✅ Use Arrow Functions: They inherit this from the surrounding scope. Interview Tip: 💡 Always check the "Call Site." No dot before the function call (like fn()) usually means this is lost! #JavaScript #CodingTips #365DaysOfCode #InterviewPrep #WebDev #FullStack #mern #react #node
To view or add a comment, sign in
-
Want Complete JavaScript Handwritten Notes? Sharing a handwritten JavaScript notes PDF covering everything from basics to advanced concepts perfect for beginners, students, and frontend developers. ✨ Variables, Data Types, Operators ✨ Functions, Arrays, Objects ✨ DOM Manipulation & Events ✨ Promises, Async/Await ✨ ES6+ Concepts & Modern JS ✨ Practical examples for revision & interviews Repost for reach and follow Harshit Mundra for more tech notes!. Credit to the original creator. #JavaScript #WebDevelopment #Frontend #CodingNotes #LearningResources
To view or add a comment, sign in
-
The map() function is one of the most commonly used methods in JavaScript — especially in React applications. It allows you to transform array data and return a new array. In this video, I explain: • How map() works internally • How it processes each element • How to modify values • Why it always returns a new array • Difference between map() and filter() Example: [1,2,3] → [2,4,6] map() is widely used for: • Rendering lists in React • Transforming API data • UI logic Understanding map is essential for writing efficient frontend code. 🎓 Learn JavaScript & React with real-world projects: 👉 https://lnkd.in/gpc2mqcf 💬 Comment Link and I’ll share the complete JavaScript roadmap. #JavaScript #ReactJS #FrontendEngineering #WebDevelopment #SoftwareEngineering #Programming #DeveloperEducation
map() Explained Simply
To view or add a comment, sign in
-
💀 Someone Said: “Go to Hell.” JavaScript Developer Took It Personally 😏 👨🦱 Random Guy: Go to hell. 👨💻 JS Developer: Callback Hell? 👨🦱: Haan wahi 😑 👨💻: Relax bro… I don't live in Callback Hell anymore. I upgraded my life to Promises 🚀 👨🦱: Oh really? Prove it. 👨💻: Fine. Let’s test your Async knowledge first 👇 🧠 Question for Real Developers </> JavaScript console.log("1"); setTimeout(() => console.log("2"), 0); Promise.resolve().then(() => { console.log("3"); setTimeout(() => console.log("4"), 0); }); Promise.resolve().then(() => console.log("5")); console.log("6"); 💬 Before You Scroll… -> Think carefully 👀 ->Call Stack clears first ->Promises go to Microtask Queue ->setTimeout goes to Macrotask Queue ->Microtasks execute before Macrotasks Now tell me… What will be the correct output order? 🤯 A) 1 2 3 4 5 6 B) 1 6 3 5 2 4 C) 1 6 2 3 5 4 D) JavaScript needs therapy Most beginners say: 👉 “setTimeout 0 means instant execution” But JavaScript be like: “Not today.” 😌 ⚡ If you understand this, You understand: ✔ Event Loop ✔ Microtask vs Macrotask ✔ Async behavior ✔ Why Promises feel faster than setTimeout 👨💻 Moral of the story: Life lesson from JavaScript — Don’t go to Callback Hell. Use Promises. Upgrade yourself. Drop your answer in comments 👇 Let’s see who actually understands Async JS 😈 Shoutout to Rohit Negi Sir 👨🏫🔥 Because of his deep explanation of Event Loop, now even “Callback Hell” feels easy to escape 😎 #JavaScript #FrontendDeveloper #AsyncProgramming #CodingHumor #WebDevelopment #DevelopersLife #TechHumor #Coderarmy
To view or add a comment, sign in
-
-
🚀 Immutability in Functional JavaScript Immutability is the principle of not modifying data after it's created. Instead of changing existing objects or arrays, we create new ones with the desired modifications. This prevents unexpected side effects and makes it easier to track data changes over time. JavaScript provides tools like `Object.assign`, the spread operator (`...`), and libraries like Immutable.js to help manage immutability. #JavaScript #WebDev #Frontend #JS #professional #career #development
To view or add a comment, sign in
-
-
You say you’re “comfortable with JavaScript”? Cool. Let’s test that. Answer these in the comments 👇 🧠 1. What will this output? Why? 𝘤𝘰𝘯𝘴𝘰𝘭𝘦.𝘭𝘰𝘨([] + []); 𝘤𝘰𝘯𝘴𝘰𝘭𝘦.𝘭𝘰𝘨([] + {}); 𝘤𝘰𝘯𝘴𝘰𝘭𝘦.𝘭𝘰𝘨({} + []); Most developers get at least one wrong. ⚡ 2. Predict the output: 𝘧𝘶𝘯𝘤𝘵𝘪𝘰𝘯 𝘰𝘶𝘵𝘦𝘳() { 𝘭𝘦𝘵 𝘤𝘰𝘶𝘯𝘵 = 0; 𝘳𝘦𝘵𝘶𝘳𝘯 𝘧𝘶𝘯𝘤𝘵𝘪𝘰𝘯 𝘪𝘯𝘯𝘦𝘳() { 𝘤𝘰𝘶𝘯𝘵++; 𝘤𝘰𝘯𝘴𝘰𝘭𝘦.𝘭𝘰𝘨(𝘤𝘰𝘶𝘯𝘵); }; } 𝘤𝘰𝘯𝘴𝘵 𝘧𝘯 = 𝘰𝘶𝘵𝘦𝘳(); 𝘧𝘯(); 𝘧𝘯(); 𝘧𝘯(); What concept is this testing? 🔥 3. What’s the difference between these two? 𝘖𝘣𝘫𝘦𝘤𝘵.𝘧𝘳𝘦𝘦𝘻𝘦(𝘰𝘣𝘫); 𝘖𝘣𝘫𝘦𝘤𝘵.𝘴𝘦𝘢𝘭(𝘰𝘣𝘫); When would you use one over the other in production? 🧩 4. True or False? 𝘵𝘺𝘱𝘦𝘰𝘧 𝘯𝘶𝘭𝘭 === "𝘰𝘣𝘫𝘦𝘤𝘵" 𝘐𝘧 𝘵𝘳𝘶𝘦 — 𝘦𝘹𝘱𝘭𝘢𝘪𝘯 𝘸𝘩𝘺. 𝘐𝘧 𝘧𝘢𝘭𝘴𝘦 — 𝘦𝘹𝘱𝘭𝘢𝘪𝘯 𝘸𝘩𝘺. 🚀 5. Async trap — what happens here? 𝘢𝘴𝘺𝘯𝘤 𝘧𝘶𝘯𝘤𝘵𝘪𝘰𝘯 𝘵𝘦𝘴𝘵() { 𝘳𝘦𝘵𝘶𝘳𝘯 42; } 𝘤𝘰𝘯𝘴𝘰𝘭𝘦.𝘭𝘰𝘨(𝘵𝘦𝘴𝘵()); What exactly gets logged? If you can answer all 5 confidently, you’re not just “using” JavaScript. You understand it. Drop your answers below 👇 Let’s see who’s interview-ready. #javascript #frontenddeveloper #codinginterview #webdevelopment #softwareengineering #DAY73
To view or add a comment, sign in
-
⚡ JavaScript Tip: Cleaner Promise Error Handling Developers often use this trick to catch sync errors in promise chains. ❌ Before Promise.resolve() .then(() => JSON.parse(data)) .then(result => console.log(result)) .catch(err => console.error(err)); ✅ Now with Promise.try() Promise.try(() => JSON.parse(data)) .then(result => console.log(result)) .catch(err => console.error(err)); ✔ Less boilerplate ✔ More readable async flows ✔ Cleaner error handling Sometimes the best language improvements are the smallest ones. Would you start using Promise.try() in your projects? #JavaScript #ESNext #NodeJS #WebDevelopment #CodingTips
To view or add a comment, sign in
-
-
🚀 JavaScript Concepts Series – Day 6 / 30 📌 Closures in JavaScript 👀 Let’s Revise the Basics 🧐 A closure is when a function remembers variables from its outer scope even after the outer function has finished execution. 🔹 Key Points • Inner function can access outer variables • Data persists even after function execution • Useful for data privacy and state management 🔹 Example function outer() { let count = 0; return function inner() { count++; console.log(count); }; } const counter = outer(); counter(); // 1 counter(); // 2 💡 Key Insight Closure → Function + its lexical scope Remembers → Outer variables after execution Closures are widely used in callbacks, event handlers, and React hooks. More JavaScript concepts coming soon. 🚀 #javascript #js #webdevelopment #frontenddeveloper #coding #programming #developers #softwaredeveloper #learnjavascript #javascriptdeveloper #codinglife #devcommunity #webdev #reactjs #mernstack #codingjourney #codeeveryday #developerlife #100daysofcode #techlearning
To view or add a comment, sign in
-
Explore related topics
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