Swap Sequential Pairs of Integers

You are given an array of lowercase single character strings as an argument. Swap each alphabetically sequential pair of characters.

If the argument array has an odd number of characters, leave the final character as it is.


  • Must return an array of strings

Example #1

solve(['a', 'b', 'c', 'd', 'e', 'f'])
> ['b', 'a', 'd', 'c', 'f', e']

Example #2

solve(['a', 'b', 'c'])
> ['b', 'a', 'c']