about | help | code help+videos | done | prefs |
Write a method that accepts an array of integers of any length. Return the array with adjacent pairs of integers "swapped". If there are an odd number of integers, the last number will not have a partner to swap with and will just remain in its regular place. swapAdjacent([5, 8, 13, 4, 7]) → [8, 5, 4, 13, 7] swapAdjacent([6]) → [6] swapAdjacent([]) → [] ...Save, Compile, Run (ctrl-enter) |
Progress graphs:
Your progress graph for this problem
Random user progress graph for this problem
Random Epic Progress Graph
Difficulty: 340
Copyright Nick Parlante 2017 - privacy