Debugging

Fix Typo in Loop

easydebuggingloopsarray
0:00

Problem

`reverseArray` should return the input array reversed. There is a typo in the loop bounds that causes it to return the wrong result. Find and fix it.

Your solution
Test results
Click Run tests to check your solution against the test cases.

About this challenge

Fix Typo in Loop is a easy debugging coding challenge. It tests your ability to read unfamiliar code, find the defect, and fix it without breaking the rest. Write your solution in the editor above, run it against the test cases, and get instant feedback — free, in your browser, no sign-up.

Show a hint & approach (spoiler)

Hint: The starting index should be arr.length - 1, not arr.length. Then you do not need the `!== undefined` guard.

Keep practicing

Browse all coding challenges, or build intuition for the underlying concepts with the algorithm visualizers and the developer cheatsheets.