Day 1/30 Write a function createCounter. It should accept an initial integer init. It should return an object with three functions. The three functions are: increment() increases the current value by 1 and then returns it. decrement() reduces the current value by 1 and then returns it. reset() sets the current value to init and then returns it. #30DaysOfCode #JavaScript #LeetCode #WebDevelopment #ProgrammingChallenge #CodingLife
Create a Counter Function in JavaScript
More Relevant Posts
-
0ms Delay... but what about the extra arguments? 🧐 Most developers know setTimeout(callback, delay), but did you know you can pass arguments directly into the callback? #JavaScript #WebDevelopment #CodingQuiz #SoftwareEngineering #FrontendTips
To view or add a comment, sign in
-
Day 83 of #100DaysOfCode Today I learned the Two Pointers technique, an important pattern for solving array problems efficiently. Covered: • Pair sum problems • Array reversal • Removing duplicates • Optimizing time complexity This technique helps reduce time complexity #DSA #CodingInterview #JavaScript #LearningInPublic
To view or add a comment, sign in
-
Day 93 / 365 👨💻 Focused on refining basics through practice. 🧩 Revisited component structure and props 🔁 Tracked state changes during interactions ⚙️ Cleaned up small parts of the code 🧠 Focused on making logic easier to follow #365DaysOfCode #React #JavaScript
To view or add a comment, sign in
-
Day 1 — Reverse a String (JavaScript) Problem Write a function that reverses a given string. Example Input: "hello" Output: "olleh" Approach Start from the last character of the string and iterate backwards. Keep adding each character to a new string until the loop finishes. Code function reverseString(str){ let reversed = "" for(let i = str.length - 1; i >= 0; i--){ reversed += str[i] } return reversed } console.log(reverseString("hello")) What I Learned Basic string traversal and how iteration works from the end of a string. #javascript #frontenddeveloper #codingpractice #dsa
To view or add a comment, sign in
-
-
JavaScript: Mirror Distance Problem Day 5 👈 Goal: Find the mirror distance of a number — the absolute difference between the number and its reversed form. Approach: Reverse the given number using modulo (%) and division. Subtract the reversed number from the original. Take the absolute value to ensure a positive result. Example: Input: 123 Reversed: 321 Mirror Distance: |123 - 321| = 198 #JavaScript #TypeScript #DSA #CodingInterview #ProblemSolving #FrontendDevelopment #Developers #100DaysOfCode
To view or add a comment, sign in
-
-
JavaScript quirk that still confuses developers: typeof null === "object" This isn’t a feature. It’s a legacy bug. Understanding the difference between: null (intentional absence) undefined (not assigned) …prevents subtle bugs in production. #javascript #webdevelopment #coding
To view or add a comment, sign in
-
JavaScript Promise chaining vs async/await: Promise chains: → Harder to read → Error handling complex → Callback-ish Async/await: → Reads like sync code → try/catch works naturally → Easier debugging The choice is obvious. #JavaScript #AsyncJS #CleanCode
To view or add a comment, sign in
-
Hoisting is a behavior in JavaScript where variable and function declarations are conceptually moved to the top of their containing scope (either the global script or a specific function) during the compilation phase, before the code is actually executed. It is important to understand that your code isn't physically moved anywhere. Instead, the JavaScript engine allocates memory for variable and function declarations before it executes the code line-by-line. #javascript #hoisting #frontend #scripting
To view or add a comment, sign in
-
-
In 1978, I wrote self-modifying code on a 12-bit machine with 4KB of RAM. Technically, 4K Words; the byte wasn't its unit. But the constraint was the same. I wrote self-modifying code on it. Not because it was clever. Because it was the only option. Four lessons from that experience that I have never unlearned — and still apply to every line of software I write. → https://lnkd.in/gBB7GW9U #Javascript #winkjs #winkComposer
To view or add a comment, sign in
-
-
3 Must-Know JavaScript Concepts for Every Developer: • Closures • Promises & Async/Await • Event Loop If you understand these well, your coding level improves significantly. Which one do you find hardest? #JavaScript #FrontendDevelopment #CodingTips
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