Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function list(list2) {
- let low = 0;
- let high = list2.length - 1;
- for (let i in list2) {
- if (low < high) {
- list2[low] = list2[high]
- list2[high] = list2[low]
- low = low + 1
- high = high - 1
- }
- }
- return list2
- }
- let list2 = [1, 3, 5, 7, 9];
- console.log(list(list2))
Advertisement
Add Comment
Please, Sign In to add comment