Advertisement
CR7CR7

reverse-with-push

Sep 18th, 2022
508
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. let numbers = [1, 2, 3, 4, 5];
  2. let reversed = [];
  3.  
  4. for (let i = numbers.length - 1; i >= 0; i--) {
  5.   reversed.push(numbers[i]);
  6. }
  7.  
  8. console.log(reversed);
  9.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement