You are given an array of objects where each object represents an item with properties such as name, category, and price.
Your task is to:
I used the filter() function to select only the objects that matched the given category. Then, I applied the map() function to create a new array where the price of each object was updated by multiplying the current price with 0.9, effectively applying a 10% discount.
Given an array of strings and a search keyword, filter the array to return only those strings that contain the search keyword. Additionally, highlight the matching portion of each string in the result.
I used the filter() function with an includes check to filter array items based on the search string. After filtering, I applied the map() function to return an HTML element for each item, where the matching part of the string is highlighted. To achieve the highlighting, I used indexOf() to find the match position and slice() to split the string into three parts—before, matching, and after—and then wrapped the matching part with a styled element.
Given a number n, generate the Fibonacci series up to n terms. The Fibonacci series is a sequence where each number is the sum of the two preceding ones, starting from 0 and 1.
I first solved the problem using the recursion method to generate the Fibonacci series. Then, as an alternative approach, I implemented the solution using a loop-based method to demonstrate a more efficient way of solving the problem.
Create a custom React Hook that stores and retrieves data from localStorage. The hook should allow persisting user input from an input box so that the value remains available even after a page refresh. This ensures data persistence and promotes code reusability across components.
I designed a custom hook for localStorage. On initialization, it ensures that localStorage is set with a default value if none exists. I then added a setter function to update the data in localStorage and bound this setter to the input element in the main component.

Here's your problem of the day
Solving this problem will increase your chance to get selected in this company
What is recursion?