Advertisement
CR7CR7

reverse

Sep 18th, 2022
491
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 = 0; i < numbers.length; i++) {
  5.   reversed[i] = numbers[numbers.length - i - 1];
  6.  
  7. }
  8.  
  9. console.log(reversed);
  10.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement