willyb321

Untitled

Aug 1st, 2017
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function list(list2) {
  2.     let low = 0;
  3.     let high = list2.length - 1;
  4.     for (let i in list2) {
  5.         if (low < high) {
  6.             list2[low] = list2[high]
  7.             list2[high] = list2[low]
  8.             low = low + 1
  9.             high = high - 1
  10.         }
  11.     }
  12.     return list2
  13. }
  14. let list2 = [1, 3, 5, 7, 9];
  15. console.log(list(list2))
Advertisement
Add Comment
Please, Sign In to add comment