Flip and Append
Two different lowercase letters a and b are given. The string of order 0 is the one-letter string a. The string of order n is the string of order n - 1 followed by a flipped copy of it, where flipping swaps every a for b and every b for a. Return the string of order n.
A loop that doubles the string n times works, but the definition is recursive: build the string of order n - 1, then append its flipped copy.
For example, n = 2, a = "x", b = "o" gives "xoox": order 0 is "x", order 1 is "xo", and order 2 is "xo" followed by its flip "ox".
Example 1
Order 1 is xo; flipping it gives ox, and appending gives xoox.
Example 2
Order 0 is just the letter a.
Constraints
0 <= n <= 5, so the result has at most 32 charactersaandbare different lowercase letters
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.