Practice
JavaScriptData StructuresReactConcepts
Sign in
← Back to problems

Loop Backwards

Fundamentals: Part 2easy

Course · Section 3: JavaScript Fundamentals – Part 2 · Lecture 49: Looping Backwards and Loops in Loops

Implement `reverseLoop(arr)` returning a new reversed array by looping from the end.

Sample tests

Input: reverseLoop([1,2,3])
Output: [3,2,1]
Input: reverseLoop([])
Output: []

+ 1 hidden test run on Submit.

Hints

Common pitfalls
  • reverse() mutates the original array.
Visualize this concept: let, const, var, and the Temporal Dead Zone →
Approach & explanation (try first)

Iterating from the last index down builds the reversed array.

Loading...
⌘/Ctrl + Enter

Run your code to see results.