Coding Brain Teaser: Write a JavaScript one-liner that prints numbers 1 to 100, but skips all numbers that contain the digit 7. Example: 1, 2, 3, 4, 5, 6, 8, 9, 10, 11, 12, 13... Think you can do it without using if statements? #JavaScript #ProblemSolving #CodeFun
Anoop Tripathi’s Post
More Relevant Posts
-
🔒 JavaScript Closures: The Private Diary Analogy Ever wondered how JavaScript "remembers" things? Let me explain closures with a real-world analogy. Think of a closure like a private diary with a lock: 📖 The diary (outer function) contains your secrets (variables) 🔐 Only you have the key (inner function) to access those secrets ✨ Even after you close the diary, the key still works Why does this matter? The count variable is trapped inside the closure. No one can directly access or modify it from outside. It's like data privacy built into JavaScript! Real-world use case : This powers every search bar you've used that waits for you to stop typing! The key insight: Closures let inner functions remember their environment, even after the outer function has finished executing. Have you used closures in your code today? Share your favorite use case below! 👇 #JavaScript #WebDevelopment #ReactJS #Programming #Frontend #CodingTips #SoftwareEngineering
To view or add a comment, sign in
-
-
Chain methods like pro - hence the secret behind `dot-dot-dot` magic! 🪄 Let's talk about method chaining in JavaScript, one of the cleanest tricks to write readable and expressive code! Day 11: Building a Chainable Calculator 🧮 🧠 Logic: 🔹 Each method (add, multiply, subtract) update the total. 🔹 All Functions returns "this", which provide the reference of same object. 🔹 By having reference, it allows the next method to be called on it directly. ✨ Result: Cleaner, more readable, and professional looking good also used widely libraries like jQuery & Lodash. #Javascript #InterviewPrep #100DaysOfCode #CodingChallenge #JavaScript #CodingInterview #JSChallenges
To view or add a comment, sign in
-
-
𝗘𝘃𝗲𝗿 𝗵𝗮𝗱 𝘆𝗼𝘂𝗿 𝗰𝗼𝗱𝗲 𝗮𝗰𝘁 𝘀𝘁𝗿𝗮𝗻𝗴𝗲 𝗮𝗻𝗱 𝘆𝗼𝘂 𝗰𝗼𝘂𝗹𝗱𝗻’𝘁 𝘁𝗲𝗹𝗹 𝘄𝗵𝘆? 😅 It happens a lot in JavaScript, especially when working with something called 𝗍𝗋𝗎𝗍𝗁𝗒 𝖺𝗇𝖽 𝖿𝖺𝗅𝗌𝗒 𝗏𝖺𝗅𝗎𝖾𝗌. In simple terms, JavaScript treats some things as true and others as false even if they don’t literally say “true” or “false.” I made a short snippet to show what I mean 👇 ✅ Lesson: Always check what’s really true or false before assuming. You can test it in the console using 𝗕𝗼𝗼𝗹𝗲𝗮𝗻(𝘃𝗮𝗹𝘂𝗲) to see if something is true or false. It’s a small thing but it can save hours of debugging. 👉 Learning by solving. 💻 #KabikaLearnsJS #JavaScript #WebDevelopment #CodingJourney #FrontendDevelopment
To view or add a comment, sign in
-
-
❓ Are “undefined” and “not defined” the same in JavaScript? Not really. In JavaScript, every declared variable automatically gets the placeholder undefined during the memory allocation phase — meaning the variable exists, but no value has been assigned yet. However, if you try to access a variable that was never declared, JavaScript throws not defined. ➡️ Undefined = declared but not assigned ➡️ Not Defined = not declared at all JavaScript is also a loosely typed language, so variables can change types freely. 💡 Pro tip: Never manually assign undefined. Let JavaScript handle that. #JavaScript #WebDevelopment #Programming #Frontend #LearningJS
To view or add a comment, sign in
-
After playing around with map(), filter(), and reduce(), I wanted to go a bit deeper into how JavaScript handles function borrowing and context binding — so I decided to rebuild call(), apply(), and bind() 💪 Here’s how my mini versions turned out 👇 🧠 What I learned: How JavaScript functions can borrow context from other objects Why bind() returns a new function (instead of calling it immediately) How important it is to handle this carefully — one tiny mistake can break everything 😅 Building these gave me a much clearer understanding of how function context and execution work in JS 🔍 #javascript #ReactJs #nodeJs #interview-questions #programming
To view or add a comment, sign in
-
-
💡 JavaScript Trivia: Did you know that in JavaScript, the expression NaN === NaN actually returns false? 🤯 That’s because NaN (Not-a-Number) is special — it’s not equal to anything, not even itself. This behavior follows the IEEE 754 standard for floating-point numbers. So if NaN isn’t equal to itself, how do we check for it? That’s where isNaN() and Number.isNaN() come in. The older isNaN() function tries to convert the value into a number before checking, which can give confusing results — for example, isNaN('hello') returns true because the string can’t be turned into a number. The newer Number.isNaN() is smarter and stricter: it only returns true when the value is literally NaN, not just something that can’t be converted to a number. ✅ Best practice: use Number.isNaN() whenever possible — it’s more predictable and avoids type coercion headaches. A tiny quirk, but one that’s tripped up many JavaScript devs (including me at some point 😅). #JavaScript #WebDevelopment #CodingTips #Programming #Trivia #Fact
To view or add a comment, sign in
-
-
💡 Understanding Object Methods in JavaScript Working with objects is fundamental in JS. Here's a quick overview of some powerful methods: Object.keys(obj) → Returns all keys of the object. Object.values(obj) → Returns all values of the object. Object.entries(obj) → Returns key-value pairs as arrays. obj.hasOwnProperty("property") → Checks if the object has a specific property. Object.assign({}, obj, { newProperty: "newValue" }) → Creates a new object by merging existing ones. 👉 View the full example on GitHub: https://lnkd.in/dDN-vDkD #JavaScript #FullStack #100xDevs #WebDevelopment #Coding #JSConcepts #LearnJavaScript
To view or add a comment, sign in
-
Recently I was preparing for JavaScript and I stumbled upon a simple concept — but most people don’t know the key differences between var and let. Here’s a quick example: ` for (var i = 0; i < 3; i++) { setTimeout(() => console.log(i), 1000); } // Output: 3 3 3 ` ` for (let i = 0; i < 3; i++) { setTimeout(() => console.log(i), 1000); } // Output: 0 1 2 ` Key differences: Scope: var is function-scoped, let is block-scoped. Hoisting & Temporal Dead Zone: var is hoisted and initialized with undefined, let is hoisted but not initialized — accessing it before declaration throws a ReferenceError. Understanding these small details can save you from tricky bugs, especially in loops and async code! #JavaScript #JS #WebDevelopment #FrontendDevelopment #Coding #LearnToCode #DeveloperTips #TechCommunity #CodeSnippet #Programming ## I’d appreciate it if you could share a few more examples to help me understand.
To view or add a comment, sign in
-
Just solved an easy-level question that’s deceptively tricky if you’re new to closures in JavaScript! 💡 Why it’s interesting: Even though the problem seems simple, it requires understanding how closures let a function “remember” variables from its outer scope. This is what allows us to ensure a function can only be called once. 🔑 Quick hint on closures: A closure is like a backpack for a function—it carries along variables from its outer function even after the outer function has finished executing. Perfect for scenarios like this! #JavaScript #LeetCode #DSA #Closures #CodingJourney
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