Find maximum
Fix the function finding the max number. The array is non-empty and contains finite numbers. Check the loop bound: reading past the array does not produce a number.
Preview challenge → Free account required to solveJAVASCRIPT IN PRACTICE
Find and fix the bug - the starter contains a defect. Trains reading other people's code and debugging.
Solving requires a free account.
Pick a challenge and explore the rules through a concrete example.
Fix the function finding the max number. The array is non-empty and contains finite numbers. Check the loop bound: reading past the array does not produce a number.
Preview challenge → Free account required to solveFix the while loop: for an integer n ≥ 0, return numbers from n down to 1, excluding zero. Return [] for n=0.
Preview challenge → Free account required to solveThis should sum 1..n but drops the last number. Fix it. n is an integer ≥ 0; the sum for 0 is 0.
Preview challenge → Free account required to solveAvailable challenges: 22.
See all challenges →The full catalogue requires a free account.
JavaScript debugging exercises develop your ability to read existing code and find the cause of incorrect behaviour. The workflow resembles handling a bug report: reproduce the issue, make a fix and check that other cases still work.
First reproduce the bug with the smallest example. Trace variable values, conditions and loop boundaries to find where the result diverges from expectations. Fix the cause and rerun all tests, including cases that already passed.
Read the description without logging in. Solving requires a free account.