FE Tech Solution#278
Open
himesh-dev wants to merge 3 commits into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Summary
Problem 1: Three Ways to Sum to N
The objective of this challenge was to provide three distinct functions that calculate the sum of all integers from one up to a given number
n. To solve this, I implemented three fundamentally different programming approaches in JavaScript. The first approach leverages a mathematical formula, offering the most efficient and direct solution. The second uses a standard iterative loop to sequentially add each number, providing a reliable fallback. The final approach relies on recursion, breaking the problem down into smaller, self-calling segments to calculate the total.Problem 2: Currency Swap Form
This task required the creation of a functional, user-friendly currency exchange form that fetches live token price data. My solution involved migrating the raw requirements into a fully modular React architecture with dedicated UI components. I engineered custom hooks to cleanly manage complex local state and separate the business logic from the presentation layer. To ensure top-tier performance, I integrated memoization techniques that prevent unnecessary component re-renders when interacting with the form. Finally, I improved overall accessibility by implementing full keyboard navigation support for the token selection dropdowns.
Problem 3: Refactoring Inefficient Wallet Code
For this challenge, I was tasked with identifying and fixing several computational inefficiencies, bugs, and anti-patterns within an existing React
WalletPagecomponent. I started by correcting flaweduseMemodependencies and broken sorting logic that failed to handle tie-breaker scenarios properly. Next, I eliminated a common React anti-pattern by swapping out array index keys for unique currency identifiers to guarantee stable rendering. To speed up execution, I replaced a heavyswitchstatement with an O(1) object lookup table and extracted it from the component lifecycle. Ultimately, these targeted refactors transform the widget into a secure, predictable, and highly performant component.