JavaScript Function Exercises
Master JavaScript functions with interactive exercises covering parameters, arguments, return values, arrow functions, callbacks, function references, rest parameters, composition, recursion, debounce, throttle, partial application, and currying. Write and test real code in your browser with immediate feedback.
Exercises
Work from beginner to hard, or use the filters to find a specific skill.
Return vs Log
A function can log one value and return a different value. The log is for someon...
Argument Order
Arguments are matched to parameters by position. JavaScript does not look at the...
Parameters Beat Nearby Values
A parameter is the input for the current function call. If a function uses a sep...
Functions as Values
A function name can be used as a value. If you store the function without parent...
Returning from Branches
A function can choose between return values. Once a branch returns, that call is...
Reusable Input Cleanup
A reusable JavaScript function should clean the input it receives and return the...
Default Parameter Labels
A default parameter is a fallback for a missing argument. It is useful when most...
Arrow Function Returns
An arrow function with an expression body returns that expression automatically....
Rest Parameters
A rest parameter gathers extra arguments into an array. That lets a function acc...
Calling a Callback
A callback is a function passed into another function. The receiving function co...
Call Result vs Function Reference
Two lines can look similar while storing very different things. A bare function ...
Callback Validation
Practice JavaScript callback validation by running an array of checks against on...
Composing Function Calls
Practice JavaScript function composition by feeding one function's return value ...
Rest Parameter Aggregation
Use JavaScript rest parameters to gather flexible numeric arguments into an aver...
Step Sequences
Practice JavaScript function sequencing by passing a value through an ordered ar...
Safe Callback Calls
Practice JavaScript callback safety by checking whether a value is callable befo...
Recursion with a Base Case
Practice JavaScript recursion by writing a function with a clear base case for a...
Function Pipelines
Practice JavaScript function pipelines by collecting transformation steps with a...
Partial Application
Practice JavaScript partial application by returning a function that remembers l...
Dispatcher Functions
Practice JavaScript dispatcher functions by creating a reusable function around ...
Recursive Tree Search
Practice JavaScript recursive search by walking nested route arrays until a path...
Debounce
Practice JavaScript debounce by returning a wrapper that delays a function call ...
Throttle
Practice JavaScript throttle by returning a wrapper that runs immediately, then ...
Curry a Function
Practice JavaScript currying by collecting arguments across several calls until ...
Factorial
Practice recursive JavaScript functions by calculating factorial values with a c...
Fibonacci
Practice JavaScript functions by calculating Fibonacci numbers from previous val...
Recursive Flatten
Practice recursive JavaScript functions by flattening nested arrays into one lis...
Practice designing functions with clear contracts
Functions turn inputs into reusable behavior and let programs separate decisions into clear, testable units. These JavaScript function exercises help you reason about parameters, arguments, calls, return values, callbacks, and composition instead of treating a function as syntax to memorize.
The collection starts with return versus console output, argument order, parameter values, functions as values, conditional returns, reusable input cleanup, default parameters, and rest parameters. Focused JavaScript arrow function practice also covers the difference between expression-body returns and block bodies that need an explicit return statement.
The JavaScript callback practice then develops into validation, safe optional calls, call-result versus function-reference mistakes, composed steps, pipelines, dispatchers, recursion, partial application, debounce, throttle, and currying. These challenges show how real functions coordinate behavior, preserve inputs, and build larger operations from smaller pieces.
- Exercises
- 27
- Difficulty
- Beginner to Hard
- Good to know first
- Know variables, expressions, and basic conditional logic; the later exercises also expect comfort with arrays and reading nested calls.
What you’ll practice
- Separate parameters from the arguments supplied by a caller
- Return useful values instead of relying on console output
- Use functions as values and distinguish references from call results
- Write arrow functions with correct implicit or explicit returns
- Call, validate, and safely handle callback functions
- Accept flexible inputs with defaults and rest parameters
- Compose steps with pipelines, dispatchers, and partial application
- Build recursive functions, debounce, throttle, and curried calls
Who these exercises are for
This practice set begins with approachable function fundamentals and progresses to advanced design patterns. It suits learners strengthening core JavaScript, developers looking for callback and arrow-function practice, and anyone who wants to write functions with clearer inputs, outputs, and responsibilities.
How practice works
- Write and run JavaScript directly in your browser
- Use instant test feedback to inspect calls and return values
- Progress from function basics to wrappers and recursive patterns
- Filter exercises by difficulty and save your progress when signed in