JavaScript Logic Practice Today I solved a JavaScript problem “Count Even Numbers in an Array.” The goal was to count how many numbers in the array are even (divisible by 2). Concepts & Methods Used: • Array.isArray() to validate input • for...of loop to iterate through the array • Modulus operator % to check even numbers • typeof and Number.isFinite() to validate numbers This practice helps improve JavaScript logic building and problem-solving skills step by step. I’m working on JavaScript logic every day to improve my coding skills. 💻 #JavaScript #CodingPractice #ProblemSolving #WebDevelopment #SoftwareDevelopment #FrontendDevelopment
Counting Even Numbers in JavaScript Array
More Relevant Posts
-
💻 JavaScript Intermediate – Custom map() Function The map() method is widely used to transform arrays. Here’s how you can implement it manually. 📌 Problem: Apply a function to each element of an array and return a new array. function customMap(arr, callback) { let result = []; for (let i = 0; i < arr.length; i++) { result.push(callback(arr[i])); } return result; } let numbers = [1, 2, 3]; let doubled = customMap(numbers, function(num) { return num * 2; }); console.log(doubled); 📤 Output: [2, 4, 6] 📖 Explanation: • map() creates a new array by applying a function to each element. • Here, we manually implemented the same logic using a loop and callback. 💡 Tip: Understanding this helps you grasp how higher-order functions work in JavaScript. #JavaScript #Coding #WebDevelopment #FrontendDevelopment #LearnToCode #ProgrammingTips
To view or add a comment, sign in
-
-
Day 4 of 30 Days of JavaScript💻....#JavaScript30 Today’s focus was on working with some of the most powerful and commonly used JavaScript array methods: 1 . filter() Used to extract specific data from arrays based on conditions. 2 . map() Learned how to transform array data into a new format. 3 . sort() Sorted complex datasets like objects and strings alphabetically and numerically. 4 . reduce() Takes an array and reduces it into one final result. Through these exercises, I understood how JavaScript can process datasets efficiently using clean and readable functional-style code. Working through these concepts step by step is helping me strengthen my logic and gain more confidence in writing JavaScript, which will definitely support me in frontend development and problem solving. #JavaScript #WebDevelopment #LearningInPublic #CodingJourney #FrontendDevelopment #30DaysOfCode
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
-
-
🚀 Day 939 of #1000DaysOfCode ✨ Object Methods in JavaScript Objects are one of the most fundamental parts of JavaScript, and knowing how to work with them efficiently can make your code much more powerful and readable. In today’s post, I’ve covered important object methods in JavaScript that every developer should know. Understanding these methods helps you manipulate data structures more effectively and write cleaner, more efficient code. If you work with JavaScript regularly, mastering object methods is definitely a must. 👇 Which JavaScript object method do you use the most in your projects? #Day939 #learningoftheday #1000daysofcodingchallenge #FrontendDevelopment #WebDevelopment #JavaScript #React #Next #CodingCommunity
To view or add a comment, sign in
-
🔍 A small JavaScript detail that can cause unexpected bugs: Object key ordering Many developers assume object keys are always returned in insertion order, but JavaScript actually follows a specific ordering rule when you iterate over object properties (Object.keys, Object.entries, for...in). The order is: • Integer index keys → sorted in ascending order • String keys → insertion order • Symbol keys → insertion order (not included in Object.keys) This is one of the reasons why using Object as a map can sometimes lead to unexpected iteration behavior when numeric keys are involved. If key order matters, Map is usually the more predictable choice since it preserves insertion order for all key types. Small language details like this are easy to overlook, but they often explain those subtle bugs you run into during debugging. #JavaScript #SoftwareEngineering #Frontend
To view or add a comment, sign in
-
-
JavaScript: Logical Operators 🧠 Want to make smart decisions in JavaScript code? Learn Logical Operators. Logical operators help your program decide what should happen next. They are used in conditions, validations, and real-world logic. Here are the 3 main ones 👇 • AND (&&) Both conditions must be true age > 18 && hasLicense • OR (||) At least one condition must be true isAdmin || isEditor • NOT (!) Reverses the result !isLoggedIn These operators are used in if statements, authentication checks, form validation, and many real projects. Small concept. Very powerful in coding. #JavaScript #WebDevelopment #FrontendDevelopment #ProgrammingBasics #LearnJavaScript #CodingForBeginners #SoftwareEngineering #DeveloperTips #TechLearning #CodeNewbie
To view or add a comment, sign in
-
-
One of my favorite JavaScript one-liners: filter(Boolean). Filtering out falsy values from an array meant chaining conditions and hoping I hadn't missed an edge case. When you pass Boolean as a callback to .filter(), JavaScript calls Boolean(item) on every element. Anything falsy - null, undefined, 0, ", false, NaN - gets removed. What you're left with is a clean array of only meaningful values. It's not just about writing less code. It's about communicating intent clearly. This pattern shines especially in real-world scenarios: cleaning up APl responses, processing user input, or combining .map) and.filter) to transform and sanitize data in a single chain. #JavaScript #WebDevelopment #SoftwareEngineering #CleanCode #Frontend #Programming #JS #CodeQuality #TechTips #Developer
To view or add a comment, sign in
-
-
Day 10 of 100 🎉 — Double digits!! In JavaScript, there is ONE value that is NOT equal to itself. Not a bug. Not a mistake. It's by design. 😱 Comment down 👇 5 lines — 5 answers! Hint: Its name literally says "Not a Number" — yet typeof says it IS a number. And isNaN vs Number.isNaN behave differently too. This one has LAYERS! 🧅 Full explanation in the comments tonight! #100DaysOfCode #JavaScript #CodingInterview #JavaScriptTips #WebDevelopment
To view or add a comment, sign in
-
-
JavaScript is "fine." Everything is "fine." 🫠 If you think you know JS, try explaining these without checking MDN: 🔹 [] + [] → "" 🔹 [] + {} → "[object Object]" 🔹 [] == ![] → true 🔹 "5" - 3 → 2 🔹 "5" + 3 → "53" Why does this happen? It all comes down to Type Coercion. * The + operator favors strings. * The - operator favors numbers. * The == operator is the "Wild West" of implicit conversion. The Fix? 1. Use === (Strict Equality) always. 2. Be explicit with your types (Number(), String()). 3. Don't add arrays to objects. Just... don't. Strong fundamentals separate the "coders" from the "engineers." What’s the most "surprising" JS behavior you’ve encountered? Let's discuss below. #FrontEnd #Coding #JavaScript #WebDev #TechCommunity
To view or add a comment, sign in
-
-
✨ Object Methods in JavaScript Objects are one of the most fundamental parts of JavaScript, and knowing how to work with them efficiently can make your code much more powerful and readable. In today’s post, I’ve covered important object methods in JavaScript that every developer should know. Understanding these methods helps you manipulate data structures more effectively and write cleaner, more efficient code. If you work with JavaScript regularly, mastering object methods is definitely a must. 👇 Which JavaScript object method do you use the most in your projects? Follow Muhammad Nouman for more useful content #learningoftheday #1000daysofcodingchallenge #FrontendDevelopment #WebDevelopment #JavaScript #React #Next #CodingCommunity
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