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 class Stack { constructor() { this.items = []; } size() { return this.items.length; } peek() { return this.items.at(-1); } push(item) { return this.items.push(item); } pop() { return...

answer
javascript
91

index.js ```js index.js export function chunk(array, size) { const chunkedArray = []; if (!Array.isArray(array)) throw TypeError("first argument is not an array"); if (!(typeof size === "number" && size > 0))...

answer
javascript
86

index.js ```js index.js export function chunk(array, size) { const result = []; if (!Array.isArray(array)) throw TypeError("first argument is not an array"); if (!(typeof size === "number" && size > 0))...

answer
javascript
86

index.js ```js index.js export const arrayReduce = (array, callback, initialValue) => { if (array == null) { throw new TypeError("arrayReduce called on null or undefined"); } if (typeof callback !==...

answer
javascript
82

index.js ```js index.js export function arrayFilter(array, callback) { const filtered = []; for (let i = 0; i < array.length; i++) { const current = array[i]; if (callback(current, i, array))...

answer
javascript
74

index.js ```js index.js export function arrayMap(array, callback) { const result = []; for (let i = 0; i < array.length; i++) { const current = array[i]; result.push(callback(current, i, array)) }...

answer
javascript
78

index.js ```js index.js export function flatten(arr, depth = 1) { const result = []; for (let i = 0; i < arr.length; i++) { const current = arr[i]; if (Array.isArray(current)...

answer
javascript
18

index.js ```js index.js const sharedObject = {}; export function A() { return sharedObject; } export function B() { return sharedObject; } ```

answer
javascript
69

index.js ```js index.js export class EventEmitter { constructor() { this.callbacks = []; } on(eventName, callback) { if (eventName in this.callbacks) { this.callbacks[eventName].push(callback); return; } this.callbacks[eventName] = [callback]; } emit(eventName, ...args)...

answer
javascript
58

index.js ```js index.js export function memo(func) { const cache = {}; return function(...args) { const key = JSON.stringify(args); if (!(key in cache)) { cache[key] = func.apply(this, args); } return cache[key];...

answer
javascript
55