Dev Duel

JavaScript Challenges

Practice fundamentals, arrays, functions, async logic, and debugging.

Filter challenges

Narrow down by difficulty or category.

Showing 45 of 45 challenges

All challenges

Practice concepts, improve problem-solving, and build confidence.

beginner5 minutes

Sum Two Values

Write a function that returns the sum of two numbers.

functionsfunctionsparameters
beginner10 minutes

Sum All Numbers in an Array Using JavaScript

Write a JavaScript function that takes an array of numbers and returns the sum of all the elements. This challenge helps you practice array iteration and basic function usage.

functionsarraysloops
beginner10 minutes

Reverse a String Using a JavaScript Function

Create a function that takes a string as input and returns the string reversed. This challenge will help you understand basic string manipulation and working with array methods in JavaScript.

functionsstring manipulationarray methods
beginner10 minutes

Beginner Challenge: Create a Function to Capitalize the First Letter of Each Word

Practice string manipulation by writing a JavaScript function that capitalizes the first letter of every word in a given sentence.

functionsstring manipulationfunctions
beginner10 minutes

Find the Largest Number in an Array

Write a function to identify the largest number within an array of integers.

functionsarraysloops
beginner10 minutes

Simple To-Do List App in JavaScript

Create a basic to-do list application where users can add tasks, mark them as completed, and see the updated list.

mini-projectsarraysobjects
intermediate15 minutes

Build a Task Tracker with Priority Sorting

Create a JavaScript function to manage and sort a list of tasks with priorities and deadlines. This mini-project simulates a simple task tracker with sorting and filtering.

mini-projectsarraysobjects
beginner10 minutes

Fix the Bug in Array Sum Function

The provided JavaScript function is supposed to sum all numbers in an array, but it contains bugs. Your task is to identify and fix the bugs so the function correctly returns the sum of the array elements.

debuggingloopsarrays
intermediate10 minutes

Build a JSON Data Filter and Sorter

Create a JavaScript function that accepts an array of JSON objects representing products, filters them based on multiple criteria, and then sorts the filtered results by a specified property.

mini-projectsArray filteringArray sorting
advanced15 minutes

Fix the Memory Leak and Logic Bug in a Recursive Deep Clone Function

This challenge provides a broken implementation of a deep clone function in JavaScript. The function is supposed to recursively clone any object or array, preserving nested structures without reference sharing. However, the current implementation has both a logic bug causing incorrect cloning of nested structures and a memory leak due to undetected circular references. Your task is to fix these issues and optimize the function for deep cloning complex objects.

debuggingrecursiondeep cloning
intermediate10 minutes

Predict the Output of a Complex Array and Object Transformation

Analyze the provided JavaScript code snippet that manipulates arrays and objects with multiple steps. Predict the exact output produced by the code.

logicArray map()Array filter()
beginner10 minutes

Build a Function to Check if a Number is Even

Create a simple JavaScript function that takes a number as input and returns true if the number is even, and false if it is odd.

functionsfunctionsconditionals
beginner10 minutes

Refactor and Simplify a Function to Calculate Total Price

Improve the readability and maintainability of a simple JavaScript function that calculates the total price of items including tax. The functionality should remain the same while making the code cleaner.

code-qualityfunctionsvariables
intermediate15 minutes

Build a Todo List Manager with Filtering and Prioritization

Create a JavaScript function that manages a list of todo items, allowing for adding, removing, updating status, and filtering tasks based on their priority and completion status.

mini-projectsclosuresarrays
advanced15 minutes

Fix Bug in Async Data Aggregation and Error Handling Function

Debug and fix a complex asynchronous JavaScript function designed to fetch and aggregate data from multiple APIs with error handling. The current implementation contains subtle bugs causing unhandled promise rejections and incorrect data aggregation.

debuggingasynchronous programmingerror handling
advanced15 minutes

Build an Advanced Debounce Function with Immediate and Cancel Options

Create a robust debounce utility function in JavaScript that delays invoking a function until after a specified wait time elapses since the last call. Support both immediate execution on the leading edge and the ability to cancel a pending invocation.

functionsclosuresasynchronous timing
intermediate10 minutes

Predict the Output: Nested Array and Object Manipulation in JavaScript

Analyze the given JavaScript code that involves nested arrays and objects with multiple transformations. Predict what the final output will be after all operations are executed.

logicarray filterarray map
beginner10 minutes

Build a Simple To-Do List App

Create a basic to-do list application in JavaScript where users can add, view, and remove tasks. This project helps beginners practice working with arrays, functions, and DOM manipulation.

mini-projectsArraysFunctions
intermediate10 minutes

Fix the Array Filtering Bug to Return Unique Even Numbers

A function meant to filter even numbers from an array and remove duplicates is currently returning incorrect results. Debug the code to ensure it returns only unique even numbers in ascending order.

debuggingarray filteringremoving duplicates
advanced45 minutes

Advanced Dynamic Form Builder with Validation in JavaScript

Build a reusable dynamic form builder function that generates interactive forms based on a JSON schema, including custom validations and conditional field visibility.

mini-projectsdynamic DOM manipulationcustom validation logic
intermediate10 minutes

Predict the Output of Nested Array and Object Destructuring with Defaults

Analyze the given JavaScript code involving nested array and object destructuring with default values and predict the final output.

logicJavaScript destructuringdefault values in destructuring
advanced10 minutes

Predict the Output of a Complex Recursive and Memoized Function

Analyze the provided JavaScript function that uses recursion, memoization, and bitwise operations to determine its output when called with a specific input.

logicrecursionmemoization
intermediate10 minutes

Build a Function to Group Objects by a Key

Create a JavaScript function that groups an array of objects by a specified key, returning an object where each key maps to an array of items sharing that key's value.

functionsarraysobjects
advanced15 minutes

Refactor Complex Data Processing Function for Improved Readability and Performance

Given a verbose and inefficient JavaScript function that processes and transforms a large dataset, refactor the code to enhance readability, maintainability, and performance without altering its output.

code-qualitycode refactoringarray manipulation
intermediate10 minutes

Refactor a Function to Cleanly Aggregate User Purchases

The provided JavaScript function processes an array of user purchase objects to calculate total spending per user. The existing code works but is messy and repetitive. Refactor it for clarity, reusability, and improved readability without changing its behavior.

code-qualityJavaScript arraysObject manipulation
advanced10 minutes

Fix Bug in Advanced Debounce Function Implementation

Identify and fix the bug in the provided advanced debounce function implementation that prevents it from correctly delaying callback execution and handling immediate invocations.

debuggingdebouncetimers
intermediate15 minutes

Build a To-Do List with JavaScript Using Objects and Arrays

Create a simple interactive to-do list mini-project where users can add, remove, and mark tasks as completed. This challenge focuses on manipulating arrays of objects and implementing multi-step logic to manage a list of tasks.

mini-projectsarraysobjects
advanced15 minutes

Build an Optimized Debounced Function Creator in JavaScript

Create a higher-order function that returns a debounced version of a given input function, ensuring optimized invocation timing and immediate execution control.

functionsclosureshigher-order functions
advanced15 minutes

Fix the Bug in Advanced Asynchronous Array Processing Function

Identify and fix the bug in the asynchronous function that processes an array of URLs to fetch JSON data and extract specific fields. The current implementation leads to incorrect results and unhandled errors.

debuggingasynchronous programmingPromise handling
intermediate10 minutes

Refactor a Function to Calculate Average Scores with Better Readability and Efficiency

Improve a messy JavaScript function that calculates average scores from an array of student objects, making the code cleaner, more efficient, and easier to understand without changing its behavior.

code-qualitycode refactoringarray methods
advanced120 minutes

Build a Real-Time Collaborative Text Editor with Operational Transformation in JavaScript

Create a real-time collaborative text editor that allows multiple users to edit a shared document simultaneously using Operational Transformation (OT) to handle concurrent changes and keep the document state consistent across clients.

mini-projectsOperational TransformationConcurrency Control
beginner10 minutes

Fix the Function to Calculate the Sum of an Array

There's a simple bug in the function that calculates the sum of numbers in an array. Your task is to identify and fix the issue so that the function returns the correct sum.

debuggingloopsvariables
advanced15 minutes

Refactor Complex Nested Callbacks into Clean Async/Await Flow

Refactor a nested callback-based event processing function into clean, modular, and maintainable async/await style JavaScript code without changing the behavior or output.

code-qualityasync/awaitcallbacks
intermediate15 minutes

Build a Task Management CLI Mini Project

Create a simple command-line task manager in JavaScript that allows users to add, remove, list, and mark tasks as complete. This mini-project will help you practice array manipulation, object handling, and implementing multi-step logic.

mini-projectsclosuresarrays
intermediate10 minutes

Fix the Bug in Array Filtering and Object Mapping Function

Identify and fix the bug in a JavaScript function designed to filter an array of user objects and map them to a list of their names based on age criteria.

debuggingarray filteringarray mapping
beginner10 minutes

Fix the Bug in a Simple Function That Adds Two Numbers

Identify and fix the bug in a JavaScript function designed to add two numbers and return the result. This challenge tests understanding of basic function syntax and return statements.

debuggingfunction syntaxreturn statement
advanced15 minutes

Build an Optimized Memoized Deep Nested Object Flattener

Create a highly efficient JavaScript function that flattens deeply nested objects into a single-level object with dot-separated keys. Implement memoization to cache and reuse results for previously processed inputs to optimize performance for repeated calls with identical objects.

functionsrecursionmemoization
intermediate15 minutes

Create a Deep Object Merge Function

Build a JavaScript function that takes two objects and merges them deeply, combining nested objects instead of overwriting them.

functionsrecursionobject manipulation
advanced10 minutes

Predict the Output of Complex Closure and Async Workflows in JavaScript

Analyze a JavaScript code snippet combining closures, async/await, Promises, and loops, then predict the exact order and content of its console output.

logicclosuresasync/await
beginner10 minutes

Create a Function to Convert Celsius to Fahrenheit

Write a JavaScript function that converts a temperature from Celsius to Fahrenheit.

functionsfunctionsarithmetic operators
intermediate20 minutes

Build a Dynamic To-Do List Manager in JavaScript

Create a small interactive to-do list manager that allows users to add, remove, edit, and toggle completion of tasks. This project will strengthen your skills with arrays, objects, DOM manipulation, and event handling in JavaScript.

mini-projectsarraysobjects
beginner10 minutes

Predict the Output of a Basic For Loop with Condition

Analyze the given JavaScript code snippet involving a for loop and conditional statements, then determine the output printed to the console.

logicfor loopconditionals
advanced45 minutes

Build a Real-Time Collaborative Todo List with Conflict Resolution

Create an advanced real-time collaborative todo list application backend function that merges concurrent updates from multiple users while resolving conflicts using operational transformation or CRDT principles in JavaScript.

mini-projectsOperational TransformationCRDT
advanced10 minutes

Predict Output: Complex Recursive Function with Memoization and Side Effects

Analyze the given JavaScript code involving recursion, memoization, and side effects, and predict what the output will be when it is executed.

logicrecursionmemoization
advanced15 minutes

Refactor Complex Data Aggregation and Filtering in JavaScript

Improve the quality and maintainability of a long, nested JavaScript function that processes and aggregates data from a complex array of objects while preserving its original behavior and performance.

code-qualitycode refactoringES6 array methods