Skip to main content
5 of 7
minor update
Arnauld
  • 197.6k
  • 20
  • 179
  • 649

##JavaScript (ES6), 37 34 bytes

f=(n,s='1')=>--n?s+f(n,++s[0]+s):s

In JavaScript, strings are immutable. Therefore, it's impossible to alter the content of the Nth character of a string s by assigning a new value to s[N].

However, the expression ++s[N] does evaluate as one would expect, even if the string remains unchanged. For instance:

++"1"[0] // equals 2

And by extension:

s = "21"
++s[0] + s // equals "321"

###Demo

f=(n,s='1')=>--n?s+f(n,++s[0]+s):s

console.log(f(6))

Arnauld
  • 197.6k
  • 20
  • 179
  • 649