How to use the JavaScript Practice Problems
- 1. Pick a problemFilter by Easy, Medium or Hard.
- 2. Write your functionKeep the function name; replace the comment with your code.
- 3. Run testsSee each input, the expected output and yours.
The problems
The 25 problems cover what placement tests and front-end interviews ask most:
- Easy (10): sum and largest of an array, reverse a string, palindrome, count vowels, FizzBuzz, factorial, even numbers, capitalise words, remove duplicates.
- Medium (11): second largest, anagrams, character frequency, deep flatten, chunking, Two Sum, missing number, group by, most frequent word, balanced brackets, Fibonacci.
- Hard (4): string compression, deep equality, longest substring without repeats, Roman numerals.
Each problem has 2–4 tests, including edge cases such as empty arrays and strings. A ✓ marks problems you have solved, and both your code and progress are saved in this browser.
Worked example
Problem 1 asks for sumArray(nums). A first try of return nums.reduce((a, b) => a + b); passes 2 of 3 tests: it fails on the empty array, because reduce with no starting value throws a TypeError on []. Adding the start value, reduce((a, b) => a + b, 0), gives 3 / 3 tests passed.
That is the habit these problems build: think about edge cases before you submit. Tips:
- Use
console.loginside your function; the output is shown under the results. - Stuck? Show a solution reveals one clear answer. Try to write it again yourself the next day.
- Your code runs in a separate worker with a 3-second limit, so an endless loop just stops instead of freezing the page.
Frequently asked questions
How are answers checked?
Your function is called with each test's input and the result is compared as JSON with the expected output.
Is my progress saved?
Yes, in your browser's local storage on this device. Clearing site data resets it.
Can I use modern JavaScript?
Yes. Arrow functions, Map, Set, spread and other modern features all work.
Is the javascript practice problems free?
Yes, it is free. Running your first tests asks for your name and WhatsApp number once. After that, the javascript practice problems and every other Uncodemy tool open with no form.