Hi folks,

I’m working on the Roman Numeral calculator and have been pretty stumped about a way to actuall do it algorithmically.

In my own solutions I’m getting pretty close and I’m sure I’ll have a breakthrough soon.

But to seek inspiration I went looking for other people’s solutions and ran across this on the web.

It works, but as hard as I try, I can’t quite figure out what to Google to find out how this actually works!

Array(+digits.join("") + 1).join(“M”)

where digits is an array containing the individual digits of the number input for the challenge.

37 broken into [“3”, “7”] for example.

I finally figured out that the + symbol before “digits” is coercing the result to be a Number rather than a String (at least I THINK that’s what it means), but the rest of it just absolutely mystifies me.

The output (if digits were [3,7] as above) would be 37 capital M’s in a row.

I can see that it works, but the notation makes it very difficult to understand **how**. How does the second join know to use 37 on each of the members? And by the way, if you don’t use the + modifier this basically just spits out the string 38 and if you use anything other than empty quotes in the first join("") it breaks entirely!

Can anyone either walk me through it, or point out a resource to go figure it out?

I get the feeling this is very, very advanced stuff that I might run into someday, but… well, I’m doing this to learn so I might as well understand it now that I’ve seen it.

Thanks!