frontend-challenges icon indicating copy to clipboard operation
frontend-challenges copied to clipboard

FrontendChallenges is a collection of frontend interview questions and answers. It is designed to help you prepare for frontend interviews. It's free and open source.

Results 109 frontend-challenges issues
Sort by recently updated
recently updated
newest added

index.js ```js index.js export function flatten(arr, depth = 1) { return arr.reduce((acc, value) => { if (Array.isArray(value) && depth > 0) { acc = acc.concat(flatten(value, depth - 1)) } else...

answer
javascript
18

index.js ```js index.js export function isEmpty(value) { switch (true) { case Array.isArray(value) && value.length > 0: return false; case value instanceof Map && value.size > 0: return false; case value...

answer
javascript
13

Let's break down the code execution: 1. `console.log(1)`: This is a synchronous operation, and it's the first line executed. 2. `const promise = new Promise((resolve) => { ... })`: The...

answer
7

index.js ```js index.js export function debounce(func, delay) { let timerId; return function() { const context = this; const args = arguments; clearTimeout(timerId); timerId = setTimeout(function() { func.apply(context, args); }, delay);...

6
answer
javascript

```js useHover.js active import { useCallback, useEffect, useRef, useState } from "react"; export function useHover() { const [hovered, setHovered] = useState(false); const ref = useRef(null); const onMouseEnter = useCallback(() =>...

3
answer
react

```js useClickOutside.js active import { useEffect } from "react"; const useClickOutside = (ref, callback) => { useEffect(() => { const handleClickOutside = (event) => { if (ref.current && !ref.current.contains(event.target)) {...

2
answer
react

There are two ways to solve this. - use `gap` property on the parent - use `margin-inline-end` property styles.css ```css styles.css body { font-family: sans-serif; } main { display: flex;...

1
answer
react

index.ts ```ts index.ts export function areAnagrams(s: string, t: string): boolean { if (s.length !== t.length) { return false; } const sFreq: Map = new Map(); const tFreq: Map = new...

answer
typescript
183

index.ts ```ts index.ts export function areAnagrams(s: string, t: string): boolean { if (s.length !== t.length) { return false; } const sortedS = sortString(s); const sortedT = sortString(t); return sortedS ===...

answer
typescript
183

index.ts ```ts index.ts export function hasDuplicate(numbers: number[]): boolean { const uniqueNumbers: Set = new Set(); for (const num of numbers) { if (uniqueNumbers.has(num)) { return true; // Duplicate found }...

answer
typescript
179