<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Srinivas on Medium]]></title>
        <description><![CDATA[Stories by Srinivas on Medium]]></description>
        <link>https://medium.com/@Srinivas_N?source=rss-40d827bf1e4e------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*SH6kUnovunvdW-ltorrsUg.jpeg</url>
            <title>Stories by Srinivas on Medium</title>
            <link>https://medium.com/@Srinivas_N?source=rss-40d827bf1e4e------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 17:51:05 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@Srinivas_N/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Cracking the Anagram Indices Problem: My Elbowcurve Interview Experience]]></title>
            <link>https://medium.com/@Srinivas_N/cracking-the-anagram-indices-problem-my-elbowcurve-interview-experience-faf3fbe99fb7?source=rss-40d827bf1e4e------2</link>
            <guid isPermaLink="false">https://medium.com/p/faf3fbe99fb7</guid>
            <category><![CDATA[coding-interviews]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[sliding-window-algorithm]]></category>
            <category><![CDATA[interview]]></category>
            <dc:creator><![CDATA[Srinivas]]></dc:creator>
            <pubDate>Sun, 30 Nov 2025 14:31:39 GMT</pubDate>
            <atom:updated>2025-11-30T14:31:39.628Z</atom:updated>
            <content:encoded><![CDATA[<p><em>A deep dive into sliding window technique, frequency maps, and O(n) optimization</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6zlkJ3g4Y1toMjmDNDsSAg.avif" /><figcaption>Elbowcurve Interview</figcaption></figure><p>Technical interviews can be unpredictable. Sometimes you get a straightforward algorithm question, and sometimes you face a problem that tests multiple concepts at once. During my recent interview with <strong>Elbowcurve</strong>, I encountered a fascinating problem that combined string manipulation, pattern matching, and optimization techniques. In this article, I’ll walk you through the problem, my thought process, and the optimal solution.</p><h3>The Interview Context</h3><p>Before diving into the coding challenge, the interviewer asked about my experience in two specific areas:</p><ul><li><strong>Rate Limiting:</strong> I discussed my implementation experience at BharatPe where we built rate limiting mechanisms for our lending platform APIs. With disbursements exceeding ₹6,000+ Crores, protecting our systems from abuse while maintaining high availability was critical.</li><li><strong>Video Streaming:</strong> At JIVI AI, I shared my experience working on video processing pipelines and real-time streaming infrastructure for our AI-powered healthcare solutions.</li></ul><p>These discussions set the stage for understanding my background before moving into the technical problem-solving portion.</p><h3>The Problem Statement</h3><p>Given a string s and a list of patterns pList, return a mapping of each valid pattern to the start indices in s where any anagram of that pattern appears.</p><h3>Constraints</h3><ul><li><strong>Ignore:</strong> Empty strings and non-string types (null, undefined, numbers)</li><li><strong>Normalize:</strong> Case-insensitive comparisons, trim whitespace</li><li><strong>Multiple anagram patterns:</strong> “abc” and “bca” can return the same indices</li></ul><h3>Test Input</h3><pre>const s = &quot;cbaebabacd&quot;;<br>const pList = [&quot;abc&quot;, &quot;bca&quot;, &quot;a&quot;, &quot;&quot;, null, &quot;acb&quot;];</pre><h3><strong>Expected Output</strong></h3><pre>{<br>  abc: [0, 6],<br>  bca: [0, 6],<br>  a: [2, 5, 7],<br>  acb: [0, 6]<br>}</pre><h3>The Key Insight: Don&#39;t Generate Permutations</h3><p>My initial instinct was to generate all permutations of each pattern and search for them. But wait — generating all permutations of a string of length k gives us k! combinations. For &quot;abc&quot; that&#39;s only 6, but for a 10-character string, that&#39;s 3,628,800 permutations!</p><blockquote>The interviewer hinted: &quot;Can you solve this in O(n) using sliding window and frequency maps?&quot;</blockquote><p>That&#39;s when it clicked: <strong>Two strings are anagrams if and only if they have identical character frequencies.</strong></p><pre>&quot;abc&quot; → { a: 1, b: 1, c: 1 }<br>&quot;cba&quot; → { a: 1, b: 1, c: 1 }  ✓ Same frequency = Anagram!<br>&quot;bac&quot; → { a: 1, b: 1, c: 1 }  ✓ Same frequency = Anagram!</pre><h3>The Sliding Window Technique</h3><p>Instead of recalculating the frequency map for every possible substring, we use a <strong>sliding window</strong> of size equal to the pattern length. As the window slides one position to the right, we:</p><ol><li>Add the new character entering the window</li><li>Remove the old character leaving the window</li><li>Compare frequency maps</li></ol><p><strong>Visual Example:</strong> Finding anagrams of “abc” in “cbaebabacd”</p><pre>s = &quot;c b a e b a b a c d&quot;<br>     0 1 2 3 4 5 6 7 8 9<br><br>[c b a] → Match at index 0 ✓<br>  [b a e] → No match<br>    [a e b] → No match<br>      [e b a] → No match<br>        [b a b] → No match<br>          [a b a] → No match<br>            [b a c] → Match at index 6 ✓<br>              [a c d] → No match</pre><h3>The Complete Solution</h3><p>Here’s the optimised JavaScript solution:</p><pre>const findAllAnagramIndices = (s, pList) =&gt; {<br>  const result = {};<br>  <br>  if (!s || typeof s !== &quot;string&quot; || !pList || !pList.length) {<br>    return result;<br>  }<br>  <br>  const normalizedS = s.toLowerCase().trim();<br>  <br>  // Helper: create frequency map from string<br>  const getFreqMap = (str) =&gt; {<br>    const freq = {};<br>    for (const char of str) {<br>      freq[char] = (freq[char] || 0) + 1;<br>    }<br>    return freq;<br>  };<br>  <br>  // Helper: compare two frequency maps<br>  const mapsAreEqual = (map1, map2) =&gt; {<br>    const keys1 = Object.keys(map1);<br>    const keys2 = Object.keys(map2);<br>    if (keys1.length !== keys2.length) return false;<br>    for (const key of keys1) {<br>      if (map1[key] !== map2[key]) return false;<br>    }<br>    return true;<br>  };<br>  <br>  // Core: sliding window function<br>  const findIndices = (text, pattern) =&gt; {<br>    const indices = [];<br>    const pLen = pattern.length;<br>    const sLen = text.length;<br>    <br>    if (pLen &gt; sLen) return indices;<br>    <br>    const patternFreq = getFreqMap(pattern);<br>    const windowFreq = getFreqMap(text.slice(0, pLen));<br>    <br>    // Check first window<br>    if (mapsAreEqual(patternFreq, windowFreq)) {<br>      indices.push(0);<br>    }<br>    <br>    // Slide the window<br>    for (let i = pLen; i &lt; sLen; i++) {<br>      const addChar = text[i];<br>      const removeChar = text[i - pLen];<br>      <br>      // Add new character<br>      windowFreq[addChar] = (windowFreq[addChar] || 0) + 1;<br>      <br>      // Remove old character<br>      windowFreq[removeChar]--;<br>      if (windowFreq[removeChar] === 0) {<br>        delete windowFreq[removeChar];<br>      }<br>      <br>      // Compare and record match<br>      if (mapsAreEqual(patternFreq, windowFreq)) {<br>        indices.push(i - pLen + 1);<br>      }<br>    }<br>    return indices;<br>  };<br>  <br>  // Process each pattern<br>  for (const pattern of pList) {<br>    if (!pattern || typeof pattern !== &quot;string&quot;) continue;<br>    <br>    const normalizedPattern = pattern.toLowerCase().trim();<br>    if (normalizedPattern.length === 0) continue;<br>    <br>    const indices = findIndices(normalizedS, normalizedPattern);<br>    if (indices.length &gt; 0) {<br>      result[pattern] = indices;<br>    }<br>  }<br>  <br>  return result;<br>};</pre><h3>Step-by-Step Breakdown of the Sliding Window</h3><p>Let’s trace through exactly what happens when we search for “abc” in “cbaebabacd”. Understanding this trace is crucial for interview discussions.</p><h3>Initial Setup</h3><pre>patternFreq = { a: 1, b: 1, c: 1 }<br>windowFreq  = { c: 1, b: 1, a: 1 }  // from &quot;cba&quot;<br>First check: MATCH! indices = [0]</pre><h3>Iteration When i = 8 (Match Found!)</h3><p>This is the critical iteration where we find our second match:</p><pre>text:    c  b  a  e  b  a  b  a  c  d<br>index:   0  1  2  3  4  5  6  7  8  9<br>                              ↑<br>                              i = 8<br><br>addChar = text[8] = &quot;c&quot;<br>removeChar = text[5] = &quot;a&quot;<br><br>BEFORE: windowFreq = { b: 1, a: 2 }<br><br>Add &quot;c&quot;: windowFreq = { b: 1, a: 2, c: 1 }<br>Remove &quot;a&quot;: windowFreq = { b: 1, a: 1, c: 1 }<br><br>Compare: { a:1, b:1, c:1 } vs { b:1, a:1, c:1 }<br>MATCH! ✓<br><br>Window start = i - pLen + 1 = 8 - 3 + 1 = 6</pre><h3>Why Delete Keys with Count Zero?</h3><p>This is a subtle but critical point. If we don’t delete keys when their count reaches zero, our comparison will fail:</p><pre>{ a: 1, b: 1, c: 1 }  vs  { a: 1, b: 1, c: 0, e: 1 }<br>     3 keys                    4 keys<br>// These won&#39;t be equal even though &quot;c&quot; has count 0!</pre><h3>Time and Space Complexity</h3><p><strong>Time: O(m × n): </strong><br>We iterate through each of the m patterns, and for each pattern, we slide through the string of length n once.</p><p><strong>Space: O(k):</strong><br>We only store frequency maps proportional to the longest pattern length k.</p><p>This is significantly better than the brute force approach of generating all permutations, which would be O(k!) for each position!</p><h3>Key Takeaways for Interviews</h3><ol><li><strong>Don’t generate permutations:</strong> Use frequency maps to compare anagrams in O(1) time per comparison.</li><li><strong>Sliding window optimization:</strong> Update incrementally instead of rebuilding from scratch.</li><li><strong>Clean up zero counts:</strong> Delete keys when count reaches zero for accurate comparisons.</li><li><strong>Handle edge cases:</strong> Validate inputs (null, empty strings, non-string types).</li><li><strong>Know your index math:</strong> i - pLen + 1 gives the window&#39;s starting position.</li></ol><h3>Interview Tips</h3><p>When you encounter this type of problem in an interview:</p><ul><li><strong>Start with the brute force approach:</strong> Explain that generating all permutations would work but is inefficient.</li><li><strong>Identify the optimization opportunity:</strong> Recognize that anagram comparison is really about character frequencies.</li><li><strong>Walk through an example:</strong> Show the interviewer your thought process with a concrete trace.</li><li><strong>Discuss trade-offs:</strong> Explain the time-space complexity and why this approach is optimal.</li></ul><h3>Conclusion</h3><p>This problem is a perfect example of how combining multiple algorithmic techniques — sliding window and frequency maps — can transform an exponential problem into a linear one. The key insight is recognizing that <strong>comparing frequencies is equivalent to checking for anagrams</strong>, but without the computational overhead of generating all permutations.</p><p>Whether you’re preparing for your next technical interview or brushing up on algorithmic patterns, understanding this approach will serve you well. It’s applicable to many string-matching and pattern-recognition problems.</p><p><strong><em>Good luck with your interviews! Feel free to connect with me on LinkedIn to discuss more interview experiences and coding challenges.</em></strong></p><p><strong>Tags:</strong> <em>#JavaScript #Algorithms #TechnicalInterview #SlidingWindow #DataStructures #CodingInterview #WebDevelopment</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=faf3fbe99fb7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[My Staff Software Engineer Interview Experience at Bazaarvoice — A Complete Breakdown]]></title>
            <link>https://medium.com/@Srinivas_N/my-staff-software-engineer-interview-experience-at-bazaarvoice-a-complete-breakdown-3ec47a7345f1?source=rss-40d827bf1e4e------2</link>
            <guid isPermaLink="false">https://medium.com/p/3ec47a7345f1</guid>
            <category><![CDATA[technical-interview]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[staff-engineer]]></category>
            <category><![CDATA[web-performance]]></category>
            <category><![CDATA[software-engineering]]></category>
            <dc:creator><![CDATA[Srinivas]]></dc:creator>
            <pubDate>Wed, 26 Nov 2025 18:41:03 GMT</pubDate>
            <atom:updated>2025-11-26T19:06:26.260Z</atom:updated>
            <content:encoded><![CDATA[<h3>My Staff Software Engineer Interview Experience at Bazaarvoice — A Complete Breakdown</h3><p><em>A detailed walkthrough of the coding round, technical questions, and what to expect when interviewing for a Staff Engineer role</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qKwdb7sJ4ep2n1tsBWdBTA.jpeg" /><figcaption>Bazaarvoice Interview Experience</figcaption></figure><p>I recently went through the interview process for a <strong>Staff Software Engineer</strong> position at <a href="https://www.bazaarvoice.com/">Bazaarvoice</a> — a leading UGC (User-Generated Content) platform that powers billions of product reviews, ratings, and authentic shopper experiences for major brands worldwide.</p><p>In this article, I’ll share my complete first-round experience, including the technical questions asked, coding challenges, and the answers I prepared. Whether you’re preparing for a similar role or just curious about what Staff-level interviews look like, I hope this helps!</p><h3>About Bazaarvoice</h3><p>Before diving into the interview, here’s some context. Bazaarvoice is a global platform that helps brands collect, manage, and syndicate authentic user-generated content. They work with billions of reviews, images, and videos — which means their engineering challenges involve high-scale distributed systems, performance optimization, and cross-platform integrations.</p><p>This context is important because the interview questions reflected these real-world challenges.</p><h3>The Interview Process Overview</h3><p>Before diving into the details, here’s the complete interview structure for the Staff Software Engineer role at Bazaarvoice:</p><p><strong>Round 1 — Coding Round</strong> JavaScript fundamentals, React concepts, performance optimization, and system thinking</p><p><strong>Round 2 — Design Patterns Round</strong> Architectural patterns, SOLID principles, and scalable design decisions</p><p><strong>Round 3 — Hiring Manager Round</strong> Leadership experience, past projects deep-dive, team fit, and technical vision</p><p><strong>Round 4 — HR Round</strong> Culture fit, compensation discussion, logistics, and final wrap-up</p><p>In this article, I’m covering <strong>Round 1 (Coding Round)</strong> in complete detail — the questions asked, how I approached them, and the answers with explanations.</p><h3>Round 1: Coding Round</h3><p>The first round was a mix of <strong>conceptual questions</strong>, <strong>JavaScript logical puzzles</strong>, and a <strong>React coding challenge</strong>. Let me break down each section.</p><h3>Part 1: Technical Conceptual Questions</h3><h3>Q1: What optimizations have you done for LCP and Layout Shift?</h3><p>This question directly relates to Core Web Vitals, which are crucial for user experience and SEO rankings. Here’s how I approached it:</p><p><strong>For LCP (Largest Contentful Paint) Optimization:</strong></p><blockquote><strong>Image Optimization</strong></blockquote><ul><li>Implemented responsive images using srcset and sizes attributes</li><li>Converted images to modern formats like WebP and AVIF with fallbacks</li><li>Used loading=&quot;eager&quot; for above-the-fold hero images (the LCP element)</li><li>Added explicit width and height attributes to prevent layout recalculation</li></ul><blockquote><strong>Critical Resource Prioritization</strong></blockquote><ul><li>Added rel=&quot;preload&quot; for critical fonts and hero images</li><li>Used fetchpriority=&quot;high&quot; on the LCP image element</li><li>Inlined critical CSS to eliminate render-blocking stylesheets</li><li>Deferred non-critical JavaScript using defer or async</li></ul><blockquote><strong>Server-Side Optimizations</strong></blockquote><ul><li>Implemented server-side rendering (SSR) for initial HTML with content</li><li>Used CDN edge caching to reduce TTFB (Time to First Byte)</li><li>Enabled Brotli/Gzip compression for faster asset delivery</li></ul><blockquote><strong>Font Optimization</strong></blockquote><ul><li>Used font-display: swap to prevent invisible text during font loading</li><li>Preloaded critical fonts with &lt;link rel=&quot;preload&quot; as=&quot;font&quot;&gt;</li><li>Subset fonts to include only required characters</li></ul><p><strong>For CLS (Cumulative Layout Shift) Optimization:</strong></p><blockquote><strong>Reserved Space for Dynamic Content</strong></blockquote><ul><li>Always specified dimensions for images, videos, and iframes</li><li>Used aspect-ratio boxes for responsive media containers</li><li>Reserved skeleton placeholders for async-loaded content</li></ul><blockquote><strong>Font Loading Strategy</strong></blockquote><ul><li>Used font-display: optional for non-critical fonts to prevent FOIT/FOUT</li><li>Matched fallback font metrics to web fonts using tools like fontaine</li></ul><blockquote><strong>Ad and Embed Handling</strong></blockquote><ul><li>Pre-allocated fixed containers for ads and third-party embeds</li><li>Used contain: layout CSS property to isolate layout shifts</li></ul><blockquote><strong>Animation Best Practices</strong></blockquote><ul><li>Avoided animating properties that trigger layout (top, left, width, height)</li><li>Used transform and opacity for animations instead</li><li>Used will-change sparingly for performance hints</li></ul><h3>Q2: Why is React better than Pure JavaScript? Why choose Next.js over React?</h3><p><strong>React vs Pure JavaScript:</strong></p><p>React isn’t inherently “better” — it’s about choosing the right tool for the job. Here’s why React shines for complex applications:</p><p><strong>DOM Updates</strong> <em>Pure JS:</em> Manual, error-prone DOM manipulation <em>React:</em> Declarative UI with automatic reconciliation</p><p><strong>State Management</strong> <em>Pure JS:</em> Custom implementation needed <em>React:</em> Built-in state and lifecycle management</p><p><strong>Component Reusability</strong> <em>Pure JS:</em> Requires discipline and patterns <em>React:</em> First-class component architecture</p><p><strong>Developer Experience</strong> <em>Pure JS:</em> More boilerplate, harder debugging <em>React:</em> DevTools, hot reloading, clear data flow</p><p><strong>Team Scalability</strong> <em>Pure JS:</em> Harder to maintain conventions <em>React:</em> Enforced patterns, easier onboarding</p><p><strong>The Real Advantages:</strong></p><ol><li><strong>Declarative Paradigm</strong>: You describe <em>what</em> the UI should look like, not <em>how</em> to update it. This reduces bugs and cognitive load.</li><li><strong>Virtual DOM</strong>: React’s diffing algorithm batches DOM updates efficiently. Instead of touching the DOM for every change, it calculates the minimal set of updates needed.</li><li><strong>Unidirectional Data Flow</strong>: Predictable state changes make debugging and testing significantly easier.</li><li><strong>Ecosystem</strong>: Battle-tested solutions for routing, state management, and styling that integrate seamlessly.</li></ol><p><strong>Why Next.js over Create React App:</strong></p><p>Next.js builds on React’s foundation and solves problems that pure React leaves to you:</p><blockquote><strong>Rendering Flexibility</strong></blockquote><ul><li>SSR (Server-Side Rendering) for SEO and initial load performance</li><li>SSG (Static Site Generation) for blazing-fast static pages</li><li>ISR (Incremental Static Regeneration) for the best of both worlds</li><li>React Server Components for reduced client-side JavaScript</li></ul><blockquote><strong>Zero-Config Optimizations</strong></blockquote><ul><li>Automatic code splitting per route</li><li>Built-in image optimization with next/image</li><li>Font optimization with automatic subsetting</li><li>Automatic prefetching of linked pages</li></ul><blockquote><strong>Developer Experience</strong></blockquote><ul><li>File-based routing (no router configuration)</li><li>API routes for backend functionality</li><li>Built-in TypeScript support</li><li>Fast Refresh for instant feedback</li></ul><blockquote><strong>Production-Ready</strong></blockquote><ul><li>Edge runtime support</li><li>Middleware for authentication, redirects, A/B testing</li><li>Built-in analytics and monitoring hooks</li></ul><h3>Q3: How does Virtual DOM play a role in faster DOM rendering?</h3><p>The Virtual DOM is one of React’s core innovations. Here’s how it works:</p><p><strong>The Problem with Direct DOM Manipulation:</strong></p><p>The browser’s DOM is expensive to modify. Each change can trigger:</p><ul><li>Style recalculation</li><li>Layout/reflow</li><li>Paint</li><li>Compositing</li></ul><p>When you update the DOM frequently (like in a dynamic UI), these operations compound, causing jank and poor performance.</p><p><strong>How Virtual DOM Solves This:</strong></p><pre>User Interaction<br>       ↓<br>State Change in React<br>       ↓<br>New Virtual DOM Tree Created (in memory - cheap!)<br>       ↓<br>Diffing Algorithm Compares Old vs New VDOM<br>       ↓<br>Minimal Set of Changes Calculated<br>       ↓<br>Batch Update to Real DOM (single reflow/repaint)</pre><p><strong>Key Concepts:</strong></p><ol><li><strong>In-Memory Representation</strong>: The Virtual DOM is a lightweight JavaScript object tree that mirrors the real DOM structure. Creating and modifying JavaScript objects is orders of magnitude faster than DOM operations.</li><li><strong>Reconciliation Algorithm</strong>: React’s diffing algorithm compares the previous and new Virtual DOM trees using heuristics:</li></ol><ul><li>Elements of different types produce different trees (full replacement)</li><li>Elements with stable key props are matched across renders</li><li>Only the changed nodes are updated in the real DOM</li></ul><p><strong>Batched Updates</strong>: React batches multiple state updates and performs a single reconciliation pass, minimizing DOM touches.</p><ol><li><strong>Batched Updates</strong>: React batches multiple state updates and performs a single reconciliation pass, minimizing DOM touches.</li><li><strong>Fiber Architecture</strong>: React’s Fiber reconciler can pause, resume, and prioritize work, ensuring smooth UI even during heavy updates.</li></ol><p><strong>Practical Example:</strong></p><pre>// Without VDOM: 1000 DOM operations<br>for (let i = 0; i &lt; 1000; i++) {<br>  document.getElementById(&#39;list&#39;).innerHTML += `&lt;li&gt;${i}&lt;/li&gt;`;<br>}<br><br>// With React/VDOM: State update → Single optimized DOM operation<br>setItems(Array.from({ length: 1000 }, (_, i) =&gt; i));</pre><h3>Q4: Cross-Microservice Communication (React, Angular, Next.js on Same Page)</h3><p>This was an interesting real-world scenario: <strong>three micro-frontends built with different frameworks (React, Angular, Next.js) need to share “offers” data without using localStorage or global stores.</strong></p><p><strong>The Solution: Custom Event Bus with Pub/Sub Pattern</strong></p><p>Since these are isolated micro-frontends potentially running in different JavaScript contexts (iframes or shadow DOM), we need a framework-agnostic communication mechanism.</p><p><strong>Approach 1: Custom Events on Window (Same Origin, No iframes)</strong></p><pre>// ═══════════════════════════════════════════════════════════════<br>// eventBus.js - Shared Event Bus (include in each micro-frontend)<br>// ═══════════════════════════════════════════════════════════════<br><br><br>class MicroFrontendEventBus {<br>  constructor(namespace = &#39;mfe&#39;) {<br>    this.namespace = namespace;<br>    this.subscriptions = new Map();<br>  }<br>  // Publish an event with data<br>  publish(eventName, data) {<br>    const event = new CustomEvent(`${this.namespace}:${eventName}`, {<br>      detail: {<br>        data,<br>        timestamp: Date.now(),<br>        source: this.getSourceIdentifier()<br>      },<br>      bubbles: true,<br>      composed: true // Crosses shadow DOM boundaries<br>    });<br>    window.dispatchEvent(event);<br>  }<br>  // Subscribe to an event<br>  subscribe(eventName, callback) {<br>    const handler = (event) =&gt; {<br>      callback(event.detail.data, event.detail);<br>    };<br>    <br>    const fullEventName = `${this.namespace}:${eventName}`;<br>    window.addEventListener(fullEventName, handler);<br>    <br>    // Store for cleanup<br>    if (!this.subscriptions.has(eventName)) {<br>      this.subscriptions.set(eventName, []);<br>    }<br>    this.subscriptions.get(eventName).push(handler);<br>    // Return unsubscribe function<br>    return () =&gt; {<br>      window.removeEventListener(fullEventName, handler);<br>    };<br>  }<br>  // Get current source identifier<br>  getSourceIdentifier() {<br>    return window.__MFE_ID__ || &#39;unknown&#39;;<br>  }<br>  // Cleanup all subscriptions<br>  destroy() {<br>    this.subscriptions.forEach((handlers, eventName) =&gt; {<br>      handlers.forEach(handler =&gt; {<br>        window.removeEventListener(`${this.namespace}:${eventName}`, handler);<br>      });<br>    });<br>    this.subscriptions.clear();<br>  }<br>}<br>// Export singleton instance<br>export const eventBus = new MicroFrontendEventBus(&#39;offers&#39;);</pre><p><strong>Usage in Each Micro-Frontend:</strong></p><pre>// ═══════════════════════════════════════════════════════════════<br>// React Micro-Frontend (Offers Provider)<br>// ═══════════════════════════════════════════════════════════════<br>import { eventBus } from &#39;./eventBus&#39;;<br><br>function OffersProvider() {<br>  const [offers, setOffers] = useState([]);<br>  const fetchOffers = async () =&gt; {<br>    const response = await fetch(&#39;/api/offers&#39;);<br>    const newOffers = await response.json();<br>    setOffers(newOffers);<br>    <br>    // Publish to other micro-frontends<br>    eventBus.publish(&#39;OFFERS_UPDATED&#39;, newOffers);<br>  };<br>  useEffect(() =&gt; {<br>    fetchOffers();<br>    const interval = setInterval(fetchOffers, 30000); // Poll every 30s<br>    return () =&gt; clearInterval(interval);<br>  }, []);<br>  return &lt;OffersList offers={offers} /&gt;;<br>}<br><br>// ═══════════════════════════════════════════════════════════════<br>// Angular Micro-Frontend (Offers Consumer)<br>// ═══════════════════════════════════════════════════════════════<br>import { eventBus } from &#39;./eventBus&#39;;<br>@Component({<br>  selector: &#39;app-offers-display&#39;,<br>  template: `&lt;div *ngFor=&quot;let offer of offers&quot;&gt;{{ offer.name }}&lt;/div&gt;`<br>})<br>export class OffersDisplayComponent implements OnInit, OnDestroy {<br>  offers: Offer[] = [];<br>  private unsubscribe: (() =&gt; void) | null = null;<br>  ngOnInit() {<br>    // Subscribe to offers updates<br>    this.unsubscribe = eventBus.subscribe(&#39;OFFERS_UPDATED&#39;, (offers) =&gt; {<br>      this.offers = offers;<br>    });<br>    // Request current state<br>    eventBus.publish(&#39;REQUEST_OFFERS&#39;, {});<br>  }<br>  ngOnDestroy() {<br>    this.unsubscribe?.();<br>  }<br>}<br><br>// ═══════════════════════════════════════════════════════════════<br>// Next.js Micro-Frontend (Offers Consumer)<br>// ═══════════════════════════════════════════════════════════════<br>&#39;use client&#39;;<br>import { eventBus } from &#39;./eventBus&#39;;<br>export default function OffersWidget() {<br>  const [offers, setOffers] = useState([]);<br>  useEffect(() =&gt; {<br>    const unsubscribe = eventBus.subscribe(&#39;OFFERS_UPDATED&#39;, (newOffers) =&gt; {<br>      setOffers(newOffers);<br>    });<br>    // Request initial state from provider<br>    eventBus.publish(&#39;REQUEST_OFFERS&#39;, {});<br>    return unsubscribe;<br>  }, []);<br>  return &lt;OffersBanner offers={offers} /&gt;;<br>}</pre><p><strong>Approach 2: PostMessage API (For iframe-based Micro-frontends)</strong></p><pre>// ═══════════════════════════════════════════════════════════════<br>// iframeBus.js - For cross-iframe communication<br>// ═══════════════════════════════════════════════════════════════<br><br>class IframeMicroFrontendBus {<br>  constructor(allowedOrigins = [&#39;*&#39;]) {<br>    this.allowedOrigins = allowedOrigins;<br>    this.handlers = new Map();<br>    <br>    window.addEventListener(&#39;message&#39;, this.handleMessage.bind(this));<br>  }<br>  handleMessage(event) {<br>    // Security: Validate origin<br>    if (!this.allowedOrigins.includes(&#39;*&#39;) &amp;&amp; <br>        !this.allowedOrigins.includes(event.origin)) {<br>      return;<br>    }<br>    const { type, payload } = event.data;<br>    if (this.handlers.has(type)) {<br>      this.handlers.get(type).forEach(cb =&gt; cb(payload, event.origin));<br>    }<br>  }<br>  // Publish to parent<br>  publishToParent(type, payload) {<br>    window.parent.postMessage({ type, payload }, &#39;*&#39;);<br>  }<br>  // Publish to specific iframe<br>  publishToIframe(iframeId, type, payload) {<br>    const iframe = document.getElementById(iframeId);<br>    iframe?.contentWindow?.postMessage({ type, payload }, &#39;*&#39;);<br>  }<br>  // Broadcast to all iframes<br>  broadcast(type, payload) {<br>    const iframes = document.querySelectorAll(&#39;iframe[data-mfe]&#39;);<br>    iframes.forEach(iframe =&gt; {<br>      iframe.contentWindow?.postMessage({ type, payload }, &#39;*&#39;);<br>    });<br>  }<br>  subscribe(type, callback) {<br>    if (!this.handlers.has(type)) {<br>      this.handlers.set(type, []);<br>    }<br>    this.handlers.get(type).push(callback);<br>    return () =&gt; {<br>      const handlers = this.handlers.get(type);<br>      const index = handlers.indexOf(callback);<br>      if (index &gt; -1) handlers.splice(index, 1);<br>    };<br>  }<br>}<br>export const iframeBus = new IframeMicroFrontendBus([<br>  &#39;https://mfe-react.example.com&#39;,<br>  &#39;https://mfe-angular.example.com&#39;,<br>  &#39;https://mfe-nextjs.example.com&#39;<br>]);</pre><p><strong>Why This Approach Works:</strong></p><ol><li><strong>Framework Agnostic</strong>: Custom Events and PostMessage are native browser APIs that work regardless of the framework.</li><li><strong>Real-time Updates</strong>: No polling required — subscribers receive updates immediately when published.</li><li><strong>Decoupled Architecture</strong>: Micro-frontends don’t need to know about each other; they only know about the event contract.</li><li><strong>Memory Safe</strong>: Proper unsubscribe functions prevent memory leaks.</li></ol><h3>Part 2: JavaScript Logical Questions</h3><h3>Question 1: Variable and Function Hoisting</h3><pre>function fn4() {<br>    var a = &#39;string1&#39;;<br>    var a = 5;<br>    console.log(a);<br><br>function logger() {<br>        console.log(&#39;this is logger 1&#39;);<br>    }<br>    function logger() {<br>        console.log(&#39;this is logger 2&#39;);<br>    }<br>    console.log(logger());<br>}<br>fn4();</pre><p><strong>Output:</strong></p><pre>5<br>this is logger 2<br>undefined</pre><p><strong>Explanation:</strong></p><p>This tests understanding of JavaScript hoisting and function declarations.</p><p><strong>Step-by-step execution:</strong></p><blockquote><strong>Hoisting Phase</strong> (before any code runs):</blockquote><ul><li>var a is hoisted and initialized to undefined</li><li>Both function logger() declarations are hoisted</li><li>The second logger function overwrites the first (same name in same scope)</li></ul><blockquote><strong>Execution Phase</strong>:</blockquote><ul><li>a = &#39;string1&#39; assigns the string</li><li>a = 5 reassigns to number (no error with var — redeclaration is allowed)</li><li>console.log(a) → prints 5</li><li>logger() executes, printing &#39;this is logger 2&#39;</li><li>logger() returns undefined (no explicit return statement)</li><li>console.log(undefined) → prints undefined</li></ul><p><strong>Key Concepts:</strong></p><ul><li>var allows redeclaration in the same scope</li><li>Function declarations are fully hoisted (both name and body)</li><li>When multiple function declarations have the same name, the last one wins</li><li>Functions without a return statement return undefined</li></ul><h3>Question 2: Closures</h3><pre>let counter = 0;<br><br>function fn1() {<br>    let message = `Counter increased to ${++counter}`;<br>    function increment() {<br>        console.log(message);<br>    }<br>    return increment;<br>}<br>const log = fn1();  // counter becomes 1, message = &quot;Counter increased to 1&quot;<br>fn1();              // counter becomes 2, but returned function is discarded<br>fn1();              // counter becomes 3, but returned function is discarded<br>log();              // Calls the function that closed over message when counter was 1</pre><p><strong>Output:</strong></p><pre>Counter increased to 1</pre><p><strong>Explanation:</strong></p><p>This is a classic closure question that tests whether you understand when variable values are captured.</p><p><strong>Key Insight:</strong> Closures capture variables at the time of their creation, not when they’re called.</p><p><strong>Step-by-step:</strong></p><p><strong>1. </strong><strong>const log = fn1()</strong> counter increments to 1. message is set to &quot;Counter increased to 1&quot;. Returns increment function that closes over this message. log now holds a reference to this function.</p><p><strong>2. </strong><strong>fn1() (second call)</strong> counter increments to 2. Creates new message = &quot;Counter increased to 2&quot;. Returns a new increment function (but we don&#39;t store it).</p><p><strong>3. </strong><strong>fn1() (third call)</strong> counter increments to 3. Creates new message = &quot;Counter increased to 3&quot;. Returns a new increment function (but we don&#39;t store it).</p><p><strong>4. </strong><strong>log()</strong> Executes the function stored from the first fn1() call. That function&#39;s closure still has message = &quot;Counter increased to 1&quot;. Prints &quot;Counter increased to 1&quot;.</p><h3>Question 3: React Grid with Sequential Color Reset</h3><p><strong>Challenge:</strong> Create a 3×3 grid where clicking boxes applies a background color. Once all 9 boxes are clicked, reset them in reverse order with 500ms intervals.</p><pre>import React, { useState, useEffect, useCallback } from &#39;react&#39;;<br><br>const GRID_SIZE = 9;<br>const RESET_DELAY = 500;<br><br>function ColorGrid() {<br>  const [clickedBoxes, setClickedBoxes] = useState(new Set());<br>  const [clickOrder, setClickOrder] = useState([]);<br>  const [isResetting, setIsResetting] = useState(false);<br><br>  // Handle box click<br>  const handleBoxClick = useCallback((index) =&gt; {<br>    // Prevent clicks during reset or on already-clicked boxes<br>    if (isResetting || clickedBoxes.has(index)) return;<br><br>    setClickedBoxes(prev =&gt; new Set([...prev, index]));<br>    setClickOrder(prev =&gt; [...prev, index]);<br>  }, [isResetting, clickedBoxes]);<br><br>  // Reset boxes in reverse order when all are clicked<br>  useEffect(() =&gt; {<br>    if (clickOrder.length === GRID_SIZE &amp;&amp; !isResetting) {<br>      setIsResetting(true);<br><br>      // Create reverse order array<br>      const reverseOrder = [...clickOrder].reverse();<br>      <br>      // Schedule removal of each box color<br>      reverseOrder.forEach((boxIndex, i) =&gt; {<br>        setTimeout(() =&gt; {<br>          setClickedBoxes(prev =&gt; {<br>            const next = new Set(prev);<br>            next.delete(boxIndex);<br>            return next;<br>          });<br><br>          // Reset everything after last box<br>          if (i === reverseOrder.length - 1) {<br>            setTimeout(() =&gt; {<br>              setClickOrder([]);<br>              setIsResetting(false);<br>            }, RESET_DELAY);<br>          }<br>        }, (i + 1) * RESET_DELAY);<br>      });<br>    }<br>  }, [clickOrder.length, isResetting]);<br><br>  return (<br>    &lt;div className=&quot;flex flex-col items-center gap-4 p-8&quot;&gt;<br>      &lt;h1 className=&quot;text-2xl font-bold&quot;&gt;Click the Boxes!&lt;/h1&gt;<br>      &lt;p className=&quot;text-gray-600&quot;&gt;<br>        Clicked: {clickOrder.length} / {GRID_SIZE}<br>        {isResetting &amp;&amp; &#39; - Resetting...&#39;}<br>      &lt;/p&gt;<br>      <br>      &lt;div className=&quot;grid grid-cols-3 gap-2&quot;&gt;<br>        {Array.from({ length: GRID_SIZE }, (_, index) =&gt; (<br>          &lt;button<br>            key={index}<br>            onClick={() =&gt; handleBoxClick(index)}<br>            disabled={isResetting}<br>            className={`<br>              w-20 h-20 border-2 border-gray-300 rounded-lg<br>              transition-all duration-300 ease-in-out<br>              flex items-center justify-center text-xl font-bold<br>              ${clickedBoxes.has(index) <br>                ? &#39;bg-blue-500 text-white border-blue-600&#39; <br>                : &#39;bg-white hover:bg-gray-100 text-gray-400&#39;}<br>              ${isResetting ? &#39;cursor-not-allowed&#39; : &#39;cursor-pointer&#39;}<br>            `}<br>          &gt;<br>            {clickOrder.indexOf(index) !== -1 <br>              ? clickOrder.indexOf(index) + 1 <br>              : &#39;&#39;}<br>          &lt;/button&gt;<br>        ))}<br>      &lt;/div&gt;<br><br>      {/* Visual order display */}<br>      &lt;div className=&quot;text-sm text-gray-500&quot;&gt;<br>        Click order: [{clickOrder.join(&#39; → &#39;)}]<br>      &lt;/div&gt;<br>    &lt;/div&gt;<br>  );<br>}<br><br>export default ColorGrid;</pre><p><strong>How It Works:</strong></p><ol><li><strong>State Management</strong> clickedBoxes is a Set of currently colored box indices. clickOrder is an Array tracking the sequence of clicks. isResetting is a Boolean to prevent clicks during reset animation.</li><li><strong>Click Handler</strong> Adds box index to both clickedBoxes and clickOrder. Prevents duplicate clicks and clicks during reset.</li><li><strong>Reset Logic</strong> Triggers when clickOrder.length === 9. Reverses the click order array. Uses setTimeout with staggered delays to remove colors one by one. Each removal happens 500ms after the previous.</li><li><strong>Visual Feedback</strong> Numbers show click sequence. Smooth color transitions. Disabled state during reset.</li></ol><h3>My Question to the Interviewer</h3><p>At the end of the round, I asked:</p><blockquote><em>“As a Staff Software Engineer, what’s the percentage split between hands-on coding and people management?”</em></blockquote><p><strong>The Answer:</strong></p><p>The interviewer shared that hands-on work would be around <strong>20–30%</strong> of the role. The majority of responsibilities would include:</p><ul><li><strong>Architecture ownership</strong> — Designing and owning the technical direction of projects</li><li><strong>Stakeholder communication</strong> — Working directly with Product Owners, other teams, and leadership</li><li><strong>Project oversight</strong> — End-to-end monitoring and delivery responsibility</li><li><strong>Team leadership</strong> — Guiding and mentoring the engineers you manage</li></ul><p>This aligned well with my expectations for a Staff-level position. At this level, the impact shifts from individual contributions to enabling the entire team to deliver better outcomes.</p><h3>Key Takeaways</h3><ol><li><strong>Core Web Vitals matter</strong> — Be ready to discuss real optimizations you’ve implemented for LCP, CLS, and FID/INP.</li><li><strong>Know your “why”</strong> — Don’t just use React or Next.js; understand and articulate the specific problems they solve.</li><li><strong>JavaScript fundamentals are critical</strong> — Hoisting, closures, and the event loop are fair game even for Staff-level roles.</li><li><strong>System design thinking</strong> — The micro-frontend communication question tests your ability to design decoupled, scalable architectures.</li><li><strong>Staff means influence</strong> — Be prepared for a role that’s more about architectural decisions and team enablement than pure coding.</li></ol><h3>Wrapping Up</h3><p>The Bazaarvoice interview was a solid mix of practical engineering knowledge and problem-solving. The questions were thoughtful and clearly designed to assess whether candidates can operate at a Staff level — where you’re expected to not just solve problems, but design systems that prevent them.</p><p>If you’re preparing for a similar role, I’d recommend:</p><ul><li>Reviewing Core Web Vitals and real-world optimization techniques</li><li>Practicing JavaScript fundamentals (they never go out of style)</li><li>Understanding micro-frontend patterns and cross-app communication</li><li>Thinking about how you’d explain your past projects’ architecture</li></ul><p>Good luck with your interviews! Feel free to reach out if you have questions.</p><p><em>Did you find this helpful? Follow me for more engineering insights and interview experiences!</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3ec47a7345f1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How AI Tools Transformed My Productivity After 10 Years in Tech]]></title>
            <link>https://medium.com/@Srinivas_N/how-ai-tools-transformed-my-productivity-after-10-years-in-tech-cccddff52d17?source=rss-40d827bf1e4e------2</link>
            <guid isPermaLink="false">https://medium.com/p/cccddff52d17</guid>
            <category><![CDATA[trending]]></category>
            <category><![CDATA[ai-tools]]></category>
            <category><![CDATA[ai-technology]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[developer]]></category>
            <dc:creator><![CDATA[Srinivas]]></dc:creator>
            <pubDate>Sun, 24 Aug 2025 06:52:24 GMT</pubDate>
            <atom:updated>2025-08-24T06:53:30.195Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ER0Ce2g7Km6tGgOdbIp_OA.webp" /></figure><p>Ten years ago, when I started my journey as a developer, productivity meant long nights of coding, endless debugging sessions, and countless hours spent finding the “right” solution. Every problem required patience, persistence, and a lot of trial and error.</p><p>Fast forward to today, and the landscape has completely changed.</p><p>Over the past few months, I’ve been working with some incredible <strong>AI tools — Gemini 2.5, Claude 3, and Sonnet</strong> — and the impact has been nothing short of transformative.</p><p>These tools don’t just make me faster. They make me <em>better</em>.</p><ul><li><strong>Brainstorming ideas</strong> that once took me hours now happens in minutes.</li><li><strong>Debugging complex issues</strong> feels less frustrating when I have an AI partner pointing me in the right direction.</li><li><strong>Prototyping applications</strong> that used to take weeks can now be done in days.</li></ul><p>For someone who has spent a decade solving problem statements and building applications, I can say with confidence: <strong>this is the most exciting era of technology I’ve ever witnessed.</strong></p><p>The real magic isn’t only about speed — it’s about focus. AI clears away the repetitive, time-consuming tasks so I can invest my energy into solving meaningful problems and building creative solutions.</p><p>And here’s the truth I’ve discovered:<br> 👉 The developers and innovators who embrace AI will move exponentially faster than those who don’t.<br> 👉 Productivity is no longer just about hard work; it’s about <em>smart collaboration</em> with AI.</p><p>We’re stepping into a future where <strong>human creativity + AI intelligence = limitless potential.</strong></p><p>If you’ve been hesitant about exploring AI, my advice is simple: <strong>don’t wait. Start experimenting now.</strong> These tools are not here to replace us; they’re here to amplify us.</p><p>💡 My takeaway after 10 years in tech: The smartest thing you can do today is learn how to partner with AI. The future belongs to those who know how to leverage it.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cccddff52d17" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[My Nagarro Walk-In Interview Experience: What to Expect at Every Round]]></title>
            <link>https://medium.com/@Srinivas_N/my-nagarro-walk-in-interview-experience-what-to-expect-at-every-round-39211350421c?source=rss-40d827bf1e4e------2</link>
            <guid isPermaLink="false">https://medium.com/p/39211350421c</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[reactjs]]></category>
            <category><![CDATA[interview]]></category>
            <category><![CDATA[aptitude]]></category>
            <category><![CDATA[nagarro]]></category>
            <dc:creator><![CDATA[Srinivas]]></dc:creator>
            <pubDate>Thu, 05 Jun 2025 07:38:45 GMT</pubDate>
            <atom:updated>2025-06-05T07:46:15.449Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yue3hk0MmxdQS1Xvfp1M0Q.png" /><figcaption>Walk in Interview</figcaption></figure><p>From Aptitude Tests to Technical Grilling — A Senior Developer’s Honest Walk-In Journey at Nagarro</p><p>Last week, I attended a <strong>walk-in interview at </strong><a href="https://www.nagarro.com/en/"><strong>Nagarro</strong></a>. They had announced multiple openings across departments like <strong>Marketing</strong>, <strong>HR</strong>, and <strong>Technology</strong>, attracting a huge crowd — <strong>over 300 candidates</strong> showed up.</p><p>Despite having over a decade of experience in frontend development, I was surprised by the structure of the process — particularly that everyone, regardless of experience level, had to take an <strong>aptitude test</strong>.</p><h3>🧠 Round 1: Aptitude Test (60 Minutes)</h3><p>This round was a mix of different skill areas:</p><ul><li>✅ <strong>20 Aptitude questions</strong></li><li>🔍 <strong>20 Reasoning questions</strong></li><li>💻 <strong>20 Technical questions</strong></li></ul><p>Personally, I found it unusual for senior-level professionals to be evaluated on aptitude, but it seems Nagarro follows this format across the board.</p><h3>💻 Round 2: Technical Interview (25 Minutes)</h3><p>This was a <strong>rapid-fire round</strong>. The interviewer had limited time and asked a string of conceptual and technical questions, including:</p><ol><li>What is <strong>Accessibility</strong>? Explain the <strong>POUR principles</strong>.</li><li>What are <strong>Progressive Web Apps (PWAs)</strong>? Share common development approaches.</li><li>What is a <strong>Micro Frontend (Micro FE)</strong>? Why choose it?</li><li>Difference between <strong>PWA</strong> and <strong>Micro Frontend</strong>.</li><li>List some <strong>frontend optimization techniques</strong>.</li><li>What are the <strong>latest React features</strong>?</li><li>How can <strong>sibling components communicate</strong> in React? Share a few methods.</li><li>Difference between useEffect, useCallback, and useMemo.</li><li>Difference between <strong>Web Workers</strong> and <strong>Service Workers</strong>.</li><li>What is <strong>Lighthouse</strong> and how is it used?</li><li>What is <strong>Tree Shaking</strong> in JavaScript?</li><li>Explain <strong>SSG</strong> (Static Site Generation) and <strong>SSR</strong> (Server Side Rendering).</li><li>Difference between <strong>Debounce</strong> and <strong>Throttle</strong> in JavaScript, with examples.</li><li>What are <strong>Web Workers</strong>? Explain with a practical use case.</li></ol><h3>🧪 Round 3: Final Technical Round (Online)</h3><p>Due to interviewer availability constraints, I was allowed to complete this round online.</p><ul><li>I answered some <strong>JavaScript</strong> and <strong>React</strong> concept-based questions.</li><li>There were <strong>2 coding problems</strong>. I completed one successfully but couldn’t get the correct output for the second one.</li></ul><h3>📩 The Result</h3><p>In the end, I wasn’t selected. The feedback was simply that they decided to proceed with other candidates. While it was disappointing, I understood — during the face-to-face round alone, there were <strong>about 15 people</strong> with similar experience levels competing for the same role.</p><h3>🔍 Final Thoughts</h3><p>While the outcome wasn’t what I hoped for, the process was insightful. Here’s what I took away:</p><ul><li>Be ready for <strong>aptitude testing</strong>, even at senior levels.</li><li>Expect <strong>fast-paced, concept-heavy technical questions</strong>.</li><li>Brush up on <strong>coding under time constraints</strong> — one small error can matter.</li><li>Even when you don’t get selected, the process is still <strong>a valuable learning opportunity</strong>.</li></ul><p>If you’re planning to attend a Nagarro walk-in, I hope this breakdown helps you prepare better. Good luck!</p><p>#Nagarro #InterviewExperience #ReactJS #FrontendDevelopment #CareerTips #JobSearch #TechInterviews #JavaScript</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=39211350421c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ Frontend Interview Prep Guide: 50+ Questions on React, JavaScript, TypeScript & More! ]]></title>
            <link>https://medium.com/@Srinivas_N/frontend-interview-prep-guide-50-questions-on-react-javascript-typescript-more-cd75169ecc30?source=rss-40d827bf1e4e------2</link>
            <guid isPermaLink="false">https://medium.com/p/cd75169ecc30</guid>
            <category><![CDATA[reactjs]]></category>
            <category><![CDATA[tech-interview]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[interview]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Srinivas]]></dc:creator>
            <pubDate>Wed, 04 Jun 2025 08:50:59 GMT</pubDate>
            <atom:updated>2025-06-04T08:50:59.401Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/626/1*OLHD_vQYY71-51HAl19Q2Q.jpeg" /><figcaption>Web Development</figcaption></figure><p>Recently, I’ve been actively interviewing for frontend developer roles, and the process has been both challenging and insightful. Across multiple technical interviews, I encountered a wide range of questions covering everything from React hooks and TypeScript nuances to JavaScript internals, performance optimization, and modern frontend architecture.</p><p>To help others prepare, I’ve compiled a comprehensive list of <strong>essential frontend interview questions</strong> that I was asked or reviewed during my prep. These span key topics like <strong>React, JavaScript, TypeScript, Next.js, CSS, performance, architecture, and more</strong>.</p><p>Whether you’re brushing up for your next interview or just want to reinforce your frontend skills, this list will be a solid resource. 💪</p><h3>🧠 Core Interview Questions to Practice</h3><ol><li>What are design patterns commonly used in React applications?</li><li>How does event delegation work in JavaScript? Can you give a practical example?</li><li>What’s the difference between useCallback, useMemo, and React.memo?</li><li>How do you send data from a child component to a parent in React?</li><li>What are controlled and uncontrolled components in React?</li><li>What is the role of keys in React’s reconciliation process?</li><li>How does useImperativeHandle work and when would you use it?</li><li>Compare call, apply, and bind in JavaScript with examples.</li><li>What is the difference between async and defer attributes on &lt;script&gt; tags?</li><li>How does hoisting work in JavaScript?</li><li>Explain the concept of the Temporal Dead Zone.</li><li>What is the Event Loop in JavaScript, and how does it affect async behavior?</li><li>Compare arrow functions vs regular functions in JavaScript.</li><li>What is function currying? Why is it useful?</li><li>What are service workers, and how are they used in web apps?</li><li>How do you implement throttling and debouncing? Provide code examples.</li><li>What is the difference between Object.freeze() and Object.seal()?</li><li>Explain error boundaries in React. How do they help in error handling?</li><li>What are semantic HTML tags and why are they important?</li><li>What are the differences between SSR and SSG in Next.js?</li><li>How can you fetch data efficiently in a Next.js app?</li><li>How do localization and globalization differ in frontend development?</li><li>What are the key principles of object-oriented programming (OOP) in JavaScript?</li><li>What is the difference between interface and type in TypeScript?</li><li>Explain how generics work in TypeScript with an example.</li><li>What are JavaScript Promises and how do .all(), .race() and .allSettled() differ?</li><li>How would you optimize performance in a React or web application?</li><li>What is the difference between useTransition and useDeferredValue in React?</li><li>What is a generator function and when should you use one?</li><li>What is the difference between sending data by value vs by reference?</li><li>How does prototypal inheritance work in JavaScript?</li><li>How do you implement lazy loading and Suspense in React?</li><li>How do you mock API calls using Jest?</li><li>What is a pure function? How is it different from a first-class function?</li><li>How do middleware like Redux Thunk and Redux Saga differ?</li><li>What does the React.Portal API do, and when would you use it?</li><li>How do you handle caching in a client-side or Node.js application?</li><li>What are polyfills, and how would you create one for Array.prototype.reduce?</li><li>What is the role of the call stack and task queue in JS execution?</li><li>How do you update React state based on the previous state?</li><li>Is setState (or useState) synchronous or asynchronous in React?</li><li>What’s the difference between Object.assign() and spread syntax in JS?</li><li>How do HOCs (Higher-Order Components) work in React? Can you write one?</li><li>Explain the render props pattern in React with a use case.</li><li>What’s the difference between fixed, absolute, and relative positioning in CSS?</li><li>How would you design a responsive UI without using a framework?</li><li>Compare client-side vs server-side caching strategies.</li><li>What are some architectural patterns for managing frontend state?</li><li>How does a WebSocket connection work under the hood?</li><li>What are some of the modern ES6+ features you use frequently?</li><li>How do you render a large list of components efficiently in React?</li><li>What’s the difference between prefetch and preload?</li><li>What is the difference between useEffect and useLayoutEffect?</li><li>How does React handle reconciliation? What happens when keys are not used correctly?</li><li>What’s the difference between Redux, Context API, and Zustand (or other state managers)?</li><li>Bonus: How do you check if a number is a decimal in JavaScript?</li></ol><h3>✨ Pro Tip</h3><p>Choose 3–5 questions a day to study, write sample code, and maybe even blog about your answers. Discuss them in interviews, peer meetups, or LinkedIn comments to reinforce your learning.</p><p>Let’s grow together!<br> If you’ve been asked other interesting questions in interviews, **drop them in the comments!**👇</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cd75169ecc30" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Guess the Number Game]]></title>
            <link>https://medium.com/@Srinivas_N/guess-the-number-game-bb496c43fe0f?source=rss-40d827bf1e4e------2</link>
            <guid isPermaLink="false">https://medium.com/p/bb496c43fe0f</guid>
            <category><![CDATA[reactjs]]></category>
            <category><![CDATA[interview-questions]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[interview]]></category>
            <dc:creator><![CDATA[Srinivas]]></dc:creator>
            <pubDate>Sun, 25 May 2025 06:33:46 GMT</pubDate>
            <atom:updated>2025-05-25T06:33:46.722Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/626/1*OLHD_vQYY71-51HAl19Q2Q.jpeg" /><figcaption>React Problems</figcaption></figure><h3>Problem Statement:</h3><p>Build a React-based game where the user guesses a randomly generated number between 1 and 100. The app should provide feedback (“Too high”, “Too low”, or “Correct”) based on the guess, track the number of attempts, and allow the game to be reset.</p><h3>Solution:</h3><pre>import React, { useEffect, useState } from &#39;react&#39;;<br><br>import &#39;./styles.css&#39;<br><br>function GuessTheNumber() {<br>  const generateRandom = () =&gt; Math.floor(Math.random() * 100) + 1;<br><br>  const [numberToGuess, setNumberToGuess] = useState(generateRandom)<br>  const [guess, setGuess] = useState(&quot;&quot;);<br>  const [message, setMessage] = useState(&quot;&quot;);<br>  const [attempts, setAttempts] = useState(0);<br><br><br><br>  // Function to handle guess checking<br>  const handleGuess = () =&gt; {<br>    console.log(&#39;numberToGuess&#39;, numberToGuess);<br>    const num = parseInt(guess);<br>    if (isNaN(num) || num &lt; 1 || num &gt; 100) {<br>      setMessage(&#39;Please enter a number between 1 and 100&#39;);<br>      return;<br>    }<br><br>    setAttempts(attempts + 1);<br><br>    if (num === numberToGuess) {<br>      setMessage(`congratulations! you guessed the number in ${attempts + 1} attempts`);<br>    } else if (num &lt; numberToGuess) {<br>      setMessage(&#39;Too low! Try again.&#39;);<br>      return;<br>    } else {<br>      setMessage(&#39;Too high! Try again.&#39;);<br>    }<br>  };<br><br>  // Function to reset the game<br>  const resetGame = () =&gt; {<br>    setNumberToGuess(generateRandom());<br>    setGuess(&quot;&quot;);<br>    setMessage(&quot;&quot;);<br>    setAttempts(0);<br>  };<br><br>  return (<br>    &lt;div style={{ display: &quot;flex&quot;, flexDirection: &quot;column&quot;, alignItems: &quot;center&quot;, margin: &quot;50px 0&quot; }}&gt;<br>      &lt;h2&gt;Guess the Number&lt;/h2&gt;<br>      &lt;input<br>      type=&quot;number&quot;<br>        placeholder=&quot;Enter a number between 1 and 100&quot;<br>        style={{ width: &quot;300px&quot;, padding: &quot;5px&quot; }}<br>        id=&quot;guess-input&quot; onChange={(e) =&gt; setGuess(e.target.value)} value={guess}<br>      /&gt;<br>      &lt;div class=&quot;btn-container&quot;&gt;<br>        &lt;button onClick={handleGuess}&gt;Check Guess&lt;/button&gt;<br>        &lt;button onClick={resetGame}&gt;Reset Game&lt;/button&gt;<br>      &lt;/div&gt;<br>      &lt;p&gt;{message}&lt;/p&gt;<br>    &lt;/div&gt;<br>  );<br>}<br><br>export default GuessTheNumber;</pre><p>I’m always open to feedback and suggestions — feel free to share your thoughts or improvements in the comments!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bb496c43fe0f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ Build a Simple & Stylish React Progress Bar Using Inline Styles]]></title>
            <link>https://medium.com/@Srinivas_N/build-a-simple-stylish-react-progress-bar-using-inline-styles-6805e7b444ab?source=rss-40d827bf1e4e------2</link>
            <guid isPermaLink="false">https://medium.com/p/6805e7b444ab</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[style]]></category>
            <category><![CDATA[trending]]></category>
            <dc:creator><![CDATA[Srinivas]]></dc:creator>
            <pubDate>Sat, 17 May 2025 21:06:30 GMT</pubDate>
            <atom:updated>2025-05-17T21:06:30.491Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/626/1*OLHD_vQYY71-51HAl19Q2Q.jpeg" /><figcaption>Progress Bar Example</figcaption></figure><p>When building React apps, we often rely on external CSS or CSS-in-JS libraries. But sometimes, inline styles are all we need — especially for quick components or demo purposes.</p><p>In this tutorial, we’ll build a clean <strong>progress bar component in React</strong> using only <strong>inline styling</strong>. No CSS files, no external dependencies — just JSX and logic.</p><h3>✨ Features of the Component</h3><ul><li>Progress updates in increments of ±10%.</li><li>Color changes based on the current progress:</li><li>Red: 0–39%</li><li>Orange: 40–79%</li><li>Green: 80–100%</li><li>Responsively styled container with transitions.</li></ul><h3>🛠️ The Code:</h3><p><strong>ProgressBar.js</strong></p><pre>import React, { useCallback, useState } from &#39;react&#39;;<br><br>function ProgressBar() {<br>    const [progress, setProgress] = useState(0);<br>    const updateProgress = (delta) =&gt; {<br>        setProgress(prev =&gt; Math.max(0, Math.min(100, prev + delta)));<br>    };<br>    const getBgColor = useCallback(() =&gt; {<br>        if (progress &gt;= 80) return &#39;green&#39;;<br>        if (progress &gt;= 40) return &#39;orange&#39;;<br>        return &#39;red&#39;;<br>    }, [progress]);<br>    return (<br>        &lt;div style={{ maxWidth: &quot;400px&quot;, margin: &quot;auto&quot;, padding: &#39;20px&#39; }}&gt;<br>            &lt;h2&gt;Progress Bar&lt;/h2&gt;<br>            &lt;div style={{<br>                height: &quot;25px&quot;,<br>                backgroundColor: &quot;#ddd&quot;,<br>                borderRadius: &quot;8px&quot;,<br>                overflow: &quot;hidden&quot;,<br>                position: &quot;relative&quot;<br>            }}&gt;<br>                &lt;div<br>                    style={{<br>                        width: `${progress}%`,<br>                        height: &quot;100%&quot;,<br>                        backgroundColor: getBgColor(),<br>                        transition: &quot;width 0.3s ease-in-out&quot;<br>                    }}<br>                &gt;<br>                    &lt;span style={{<br>                        position: &quot;absolute&quot;,<br>                        top: &quot;0&quot;,<br>                        left: &quot;50%&quot;,<br>                        transform: &quot;translateX(-50%)&quot;,<br>                        color: &quot;#fff&quot;,<br>                        fontWeight: &quot;bold&quot;<br>                    }}&gt;<br>                        {progress}%<br>                    &lt;/span&gt;<br>                &lt;/div&gt;<br>            &lt;/div&gt;<br>            &lt;div style={{ marginTop: &quot;10px&quot; }}&gt;<br>                &lt;button onClick={() =&gt; updateProgress(-10)}&gt;-10%&lt;/button&gt;<br>                &lt;button onClick={() =&gt; updateProgress(+10)} style={{ marginLeft: &quot;10px&quot; }}&gt;+10%&lt;/button&gt;<br>            &lt;/div&gt;<br>        &lt;/div&gt;<br>    );<br>}<br>export default ProgressBar;</pre><p><strong>App.js:</strong></p><pre>import ProgressBars from &quot;./ProgressBars&quot;;<br><br>export default function App() {<br>    return &lt;ProgressBars /&gt;;<br>}</pre><h3>✅ What You’ll Learn</h3><ul><li>How to <strong>use inline styles</strong> effectively in React</li><li>Dynamic styling with useCallback and state</li><li>Keeping your UI logic simple and maintainable</li></ul><h3>💡 Why Inline Styles?</h3><p>You might choose inline styles when:</p><ul><li>You need a <strong>quick prototype</strong>.</li><li>The component is <strong>self-contained</strong>.</li><li>You’re working in <strong>restricted environments</strong> like email clients, widget SDKs, or drag-and-drop page builders.</li></ul><p>That said, for larger apps, consider styled-components, CSS Modules, or Tailwind CSS.</p><h3>🧠 Final Thoughts</h3><p>This small component is a great example of how <strong>React’s state + inline styles</strong> can go a long way. It’s readable, simple, and very easy to tweak.</p><p>Want to enhance it further? Try:</p><ul><li>Adding emojis for milestone levels</li><li>Making the color palette customizable via props</li><li>Adding keyboard accessibility</li></ul><p>Let me know if you’d like help turning this into a properly formatted Medium draft with embedded CodeSandbox demo, preview image, and tags.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6805e7b444ab" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ Password Strength Checker]]></title>
            <link>https://medium.com/@Srinivas_N/problem-statement-ca89c106aae2?source=rss-40d827bf1e4e------2</link>
            <guid isPermaLink="false">https://medium.com/p/ca89c106aae2</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[problem-solving]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[preparation]]></category>
            <category><![CDATA[reactjs]]></category>
            <dc:creator><![CDATA[Srinivas]]></dc:creator>
            <pubDate>Sat, 17 May 2025 16:43:54 GMT</pubDate>
            <atom:updated>2025-05-17T16:44:18.481Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/626/1*OLHD_vQYY71-51HAl19Q2Q.jpeg" /><figcaption>Web Development</figcaption></figure><p>In today’s digital age, password security is more important than ever. Users often struggle to create strong passwords, and many applications don’t offer immediate feedback on password strength. This can lead to weak passwords that are vulnerable to attacks.</p><p><strong>The goal</strong> is to build a simple yet effective <strong>Password Strength Checker</strong> using <strong>React</strong>, which evaluates a user’s input against key strength criteria:</p><ul><li>Minimum length of 8 characters</li><li>Contains uppercase letters</li><li>Contains lowercase letters</li><li>Includes numeric digits</li><li>Includes special characters</li></ul><p>Based on how many of these criteria are met, the component will classify the password into one of several strength levels (Level 1, Level 2, Level 3) and provide real-time feedback to the user.</p><p>This tool not only improves user experience but also promotes better security practices by encouraging stronger password creation.</p><p>You can follow this up with sections like:</p><ul><li>Why password strength matters</li><li>Breakdown of the strength evaluation logic</li><li>React component walkthrough</li><li>Styling and UX considerations</li><li>How to test and extend it further</li></ul><h3>Solution:</h3><p><strong>App.js:</strong></p><pre>import PasswordStrength from &#39;./PasswordStrength&#39;<br>export default function App() {<br>  return &lt;PasswordStrength/&gt;<br>}</pre><p><strong>PasswordStrength.js:</strong></p><pre>import React, { useState } from &#39;react&#39;;<br>import &#39;./styles.css&#39;<br><br>// ✅ Export this so it can be tested <br>export const checkPasswordStrength = (pwd) =&gt; {<br>  const checks = [<br>    pwd.length &gt;= 8,<br>    /[A-Z]/.test(pwd),<br>    /[a-z]/.test(pwd),<br>    /[0-9]/.test(pwd),<br>    /[^A-Za-z0-9]/.test(pwd),<br>  ];<br><br>  const passed = checks.filter(Boolean).length;<br><br>  if (passed === 1) return &#39;Level 1&#39;;<br>  if (passed &gt;= 2 &amp;&amp; passed &lt;= 3) return &#39;Level 2&#39;;<br>  if (passed &gt;= 4 &amp;&amp; passed &lt;= 5) return &#39;Level 3&#39;;<br>  return &#39;Weak Password&#39;;<br>};<br><br>const PasswordStrength = () =&gt; {<br>  const [password, setPassword] = useState(&#39;&#39;);<br>  const [passwordStr, setPasswordStr] = useState(&#39;&#39;);<br><br>  return (<br>    &lt;div&gt;<br>      &lt;h2&gt;Password Strength Checker&lt;/h2&gt;<br>      &lt;div&gt;<br>        &lt;input type=&quot;password&quot; onChange={(e) =&gt; setPassword(e.target.value)} value={password} /&gt;<br>        &lt;button style={{ marginLeft: &#39;10px&#39; }} onClick={() =&gt; setPasswordStr(checkPasswordStrength(password))}&gt;Check Strength&lt;/button&gt;<br>      &lt;/div&gt;<br>      {passwordStr ? (&lt;p&gt;Strength:&lt;span style={{ fontWeight: &#39;bold&#39; }}&gt;{passwordStr}&lt;/span&gt;&lt;/p&gt;) : null}<br><br>    &lt;/div &gt;<br>  );<br>};<br><br>export default PasswordStrength;</pre><p><strong>styles.css:</strong></p><pre>body {<br>  font-family: sans-serif;<br>  -webkit-font-smoothing: auto;<br>  -moz-font-smoothing: auto;<br>  -moz-osx-font-smoothing: grayscale;<br>  font-smoothing: auto;<br>  text-rendering: optimizeLegibility;<br>  font-smooth: always;<br>  -webkit-tap-highlight-color: transparent;<br>  -webkit-touch-callout: none;<br>}<br><br>h1 {<br>  font-size: 1.5rem;<br>}</pre><h3>Output:</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/958/1*nLLNGSZIV8W716LT2ZxcKw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/958/1*hMp7NMQB64gIBCuwJnykCw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/954/1*rJD1PYZ4iQlhPAJW56wCEw.png" /></figure><p>I’m always open to feedback and suggestions — feel free to share your thoughts or improvements in the comments!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ca89c106aae2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ Problem Statement: Build a Mortgage Calculator in React]]></title>
            <link>https://medium.com/@Srinivas_N/problem-statement-build-a-mortgage-calculator-in-react-5e143d051435?source=rss-40d827bf1e4e------2</link>
            <guid isPermaLink="false">https://medium.com/p/5e143d051435</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[problem-solving]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Srinivas]]></dc:creator>
            <pubDate>Sat, 17 May 2025 15:43:07 GMT</pubDate>
            <atom:updated>2025-05-17T15:43:07.198Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/626/1*OLHD_vQYY71-51HAl19Q2Q.jpeg" /><figcaption>Web Development</figcaption></figure><p>Create a <strong>Mortgage Calculator</strong> web application using <strong>React</strong> that allows users to input key loan details and calculates the <strong>monthly payment (EMI)</strong> based on those inputs.</p><p>🔧 <strong>Requirements:</strong></p><ol><li><strong>Inputs</strong>:</li></ol><ul><li><strong>Loan Amount (INR)</strong> — the principal loan amount.</li><li><strong>Annual Interest Rate (%)</strong> — the annual interest rate as a percentage.</li><li><strong>Loan Term (Years)</strong> — the total loan duration in years.</li></ul><p><strong>2. Functionality</strong>:</p><ul><li>On clicking the <strong>“Calculate”</strong> button, compute the monthly payment using the standard EMI formula:</li><li>EMI=P×R×(1+R)N(1+R)N−1EMI = \frac{P \times R \times (1 + R)^N}{(1 + R)^N — 1}EMI=(1+R)N−1P×R×(1+R)N​</li><li>Where:</li><li>PPP = Principal (Loan Amount)</li><li>RRR = Monthly Interest Rate (Annual Rate ÷ 12 ÷ 100)</li><li>NNN = Total number of payments (Loan Term × 12)</li></ul><p><strong>3. Output</strong>:</p><ul><li>Display the <strong>monthly payment</strong> below the form when calculated.</li><li>Include a visible &lt;label&gt; with the text &quot;Result&quot; associated with the output.</li></ul><h3>✅ Constraints:</h3><ul><li>Use React functional components and hooks (useState, useCallback).</li><li>Follow accessibility best practices (labels must be properly associated with inputs).</li><li>Ensure the form passes basic unit tests (such as those used in HackerRank/React Testing Library).</li></ul><h3>Solution:</h3><p>MortageCalculator.js:</p><pre>import React, { useCallback, useMemo, useState } from &#39;react&#39;;<br>import &#39;./styles.css&#39;<br><br>function MortgageCalculator() {<br>  const [loanAmount, setLoanAmount] = useState(&#39;&#39;);<br>  const [monthlyPayment, setMonthlyPayment] = useState(&#39;&#39;);<br>  const [interestRate, setInterestRate] = useState(&#39;&#39;);<br>  const [termYears, setTermYears] = useState(&#39;&#39;);<br><br>  const calculateMonthlyAmt = useCallback(() =&gt; {<br>    if (loanAmount &lt;= 0 || interestRate &lt;= 0 || termYears &lt;= 0) {<br>      setMonthlyPayment(&quot;Invalid input&quot;);<br>      return;<br>    }<br><br>    const monthlyInt = (interestRate / 100) / 12;<br>    const termMonths = termYears * 12;<br><br>    const data = loanAmount * ((monthlyInt * Math.pow((1 + monthlyInt), termMonths)) / (Math.pow((1 + monthlyInt), termMonths) - 1));<br>    console.log(&#39;dataaaa&#39;, data, loanAmount, monthlyInt, termMonths);<br>    setMonthlyPayment(data.toFixed(2));<br><br>  }, [loanAmount, termYears])<br><br>  const renderInputSection = useCallback((id, label, inputState) =&gt; {<br>    return (<br>      &lt;div className=&quot;input-section&quot;&gt;<br>        &lt;label htmlFor={id}&gt;{label}:&lt;/label&gt;<br>        &lt;input<br>          type=&quot;number&quot;<br>          id={id}<br>          name={id}<br>          onChange={(e) =&gt; inputState(e.target.value)}<br>        /&gt;<br>      &lt;/div&gt;<br>    );<br>  }, []);<br><br>  return (<br>    &lt;div className=&quot;input-container&quot;&gt;<br>      {renderInputSection(&#39;loan_amount&#39;, &#39;Loan Amount (INR)&#39;, setLoanAmount)}<br>      {renderInputSection(&#39;interest_rate&#39;, &#39;Annual Interest Rate (%)&#39;, setInterestRate)}<br>      {renderInputSection(&#39;loan_term&#39;, &#39;Loan Term (Years)&#39;, setTermYears)}<br><br>      &lt;button className=&quot;cals-btn&quot; onClick={calculateMonthlyAmt}&gt;Calculate&lt;/button&gt;<br><br>      {monthlyPayment != null ? (<br>        &lt;div className=&quot;input-section&quot; aria-label=&quot;result&quot;&gt;<br>          Monthly Payment: {monthlyPayment}<br>        &lt;/div&gt;<br>      ) : null}<br><br><br>    &lt;/div&gt;);<br>}<br><br>export default MortgageCalculator;</pre><p>App.js</p><pre>import MortgageCalculator from &quot;./MortgageCalculator&quot;;<br><br>export default function App() {<br>  return &lt;MortgageCalculator /&gt;;<br>}</pre><p>styles.css</p><pre>body {<br>  font-family: sans-serif;<br>  -webkit-font-smoothing: auto;<br>  -moz-font-smoothing: auto;<br>  -moz-osx-font-smoothing: grayscale;<br>  font-smoothing: auto;<br>  text-rendering: optimizeLegibility;<br>  font-smooth: always;<br>  -webkit-tap-highlight-color: transparent;<br>  -webkit-touch-callout: none;<br>}<br><br>h1 {<br>  font-size: 1.5rem;<br>}<br><br>.input-container {<br>  display: flex;<br>  flex-direction: column;<br>}<br><br>.input-section {<br>  display: flex;<br>  flex-direction: row;<br>  margin-bottom: 10px;<br><br>  input {<br>    margin-left: 10px;<br>  }<br>}<br><br>.cals-btn {<br>  padding: 10px 5px;<br>}</pre><h3>Demo:</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*k0xzj1QJkrgpQRIEk6gAhw.gif" /><figcaption>Demo</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5e143d051435" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ Problem Statement: Chips Input in React]]></title>
            <link>https://medium.com/@Srinivas_N/problem-statement-chips-input-in-react-4b5510b8a0a9?source=rss-40d827bf1e4e------2</link>
            <guid isPermaLink="false">https://medium.com/p/4b5510b8a0a9</guid>
            <category><![CDATA[reactjs]]></category>
            <category><![CDATA[practice]]></category>
            <category><![CDATA[trending]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[interview]]></category>
            <dc:creator><![CDATA[Srinivas]]></dc:creator>
            <pubDate>Fri, 16 May 2025 17:49:55 GMT</pubDate>
            <atom:updated>2025-05-16T18:33:52.163Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/626/1*OLHD_vQYY71-51HAl19Q2Q.jpeg" /><figcaption>React Questions</figcaption></figure><p>Build a <strong>Chips Input</strong> component in React that allows users to add and remove tags (chips) using specific interactions.</p><h3>📝 Chips Input — Requirements</h3><ul><li>User can type in a text input.</li><li>When user presses <strong>Enter</strong>, the typed value becomes a chip.</li><li><strong>Empty or duplicate</strong> chips should not be added.</li><li>Each chip should have a <strong>close (×)</strong> icon.</li><li>Clicking the <strong>close icon</strong> removes that chip.</li><li>Chips should be displayed in a row with basic styling.</li><li>After adding a chip, the input should clear.</li><li>Support optional props:</li><li>initialChips – to show default chips.</li><li>onChange – to send updated chips list to parent.</li></ul><h3>Solution:</h3><p>App.js:</p><pre>import ChipsInput from &#39;./ChipsInput.js&#39;<br>export default function App() {<br>  return &lt;ChipsInput/&gt;<br>}</pre><p>ChipsInput.js:</p><pre>import React, { useCallback, useState } from &quot;react&quot;;<br><br>import &quot;./styles.css&quot;;<br><br>function ChipsInput() {<br>  const [chips, setChips] = useState([]);<br>  const [chipVal, setChipVal] = useState(&quot;&quot;);<br><br>  const handleKeyPress = useCallback(<br>    (event) =&gt; {<br>      if (event.key === &quot;Enter&quot;) {<br>        const val = chipVal.trim();<br><br>        if (val.length &gt; 0 &amp;&amp; chips.indexOf(val) === -1) {<br>          setChips(prev =&gt; [...prev, val]);<br>        }<br>        setChipVal(&#39;&#39;);<br>      }<br>    },<br>    [chips, chipVal],<br>  );<br><br>  const onRemoveChip = useCallback((index) =&gt; {<br>    setChips(prev =&gt; prev.filter((_, i) =&gt; i !== index));<br>  }, [chips]);<br><br>  return (<br>    &lt;div<br>      style={{<br>        display: &quot;flex&quot;,<br>        flexDirection: &quot;column&quot;,<br>        alignItems: &quot;center&quot;,<br>        margin: &quot;40px 0&quot;,<br>      }}<br>    &gt;<br>      &lt;h2&gt;Chips Input&lt;/h2&gt;<br>      &lt;input<br>        type=&quot;text&quot;<br>        placeholder=&quot;Type a chip and press tag&quot;<br>        style={{ padding: &quot;8px&quot;, width: &quot;200px&quot; }}<br>        value={chipVal}<br>        onChange={(e) =&gt; setChipVal(e.target.value)}<br>        onKeyDown={handleKeyPress}<br>      /&gt;<br><br>      &lt;div class=&quot;chips-section&quot;&gt;<br>        {chips.length &gt; 0 ? (chips.map((chip, index) =&gt; {<br>          return (<br>            &lt;div class=&quot;chip-input&quot; key={index}&gt;<br>              &lt;span class=&quot;chip-text&quot;&gt;{chip}&lt;/span&gt;<br>              &lt;button class=&quot;cross-icon&quot; onClick={() =&gt; onRemoveChip(index)}&gt;<br>                X<br>              &lt;/button&gt;<br>            &lt;/div&gt;<br>          );<br>        })) : &lt;p&gt;No Chips Found&lt;/p&gt;}<br>      &lt;/div&gt;<br>    &lt;/div&gt;<br>  );<br>}<br><br>export default ChipsInput;</pre><p>Styles.css:</p><pre>body {<br>  font-family: sans-serif;<br>  -webkit-font-smoothing: auto;<br>  -moz-font-smoothing: auto;<br>  -moz-osx-font-smoothing: grayscale;<br>  font-smoothing: auto;<br>  text-rendering: optimizeLegibility;<br>  font-smooth: always;<br>  -webkit-tap-highlight-color: transparent;<br>  -webkit-touch-callout: none;<br>}<br><br>h1 {<br>  font-size: 1.5rem;<br>}<br><br>.chips-section {<br>  display: flex;<br>  flex-direction: row;<br>  padding: 10px;<br>  flex-wrap: wrap;<br>  margin-bottom: 20px;<br>}<br><br>.chip-input {<br>  display: flex;<br>  flex-direction: row;<br>  margin: 8px 5px;<br>  border: 1px solid #CACACA;<br>  padding: 5px;<br>  border-radius: 5px;<br>  align-items: center;<br>}<br><br>.chip-text {<br>  color: green;<br>}<br><br>.cross-icon {<br>  color: red;<br>  margin-left: 10px;<br>  border-radius: 50px;<br>  padding: 5px 8px;<br>}</pre><p>Output UI :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/884/1*trVnAQUF3Gv9DU9EJIjEHA.png" /><figcaption>Output UI</figcaption></figure><p>I’m always open to feedback and suggestions — feel free to share your thoughts or improvements in the comments!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4b5510b8a0a9" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>