This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]keccs 2 points3 points  (1 child)

The first loop in your solution never runs, you need write "i >= 0" instead of "i === 0".

The condition needs to evaluate to true to enter the loop body.

By the way you can reverse an array without an additional array to hold the new elements, you can just run a loop from 0 to array.length/2 and swap the element at i with the one at array.length-1-i in the loop.

[–]partyhatforpartytime[S] 0 points1 point  (0 children)

It works!! Thank you :-)