← Back to challenges

ABACABA Pattern

JavaScriptHardrecursiongeometry

Instructions

The ABACABA pattern is a recursive fractal pattern that shows up in many places in the real world (such as in geometry, art, music, poetry, number systems, literature and higher dimensions).

Create a function that takes a number n as an argument and returns a string that represents the full pattern.

Examples

abacabaPattern(1) ➞ "A"

abacabaPattern(2) ➞ "ABA"

abacabaPattern(3) ➞ "ABACABA"

Notes

  • Result should always be uppercase.
javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.