It take ten minutes to find the logic of code. I never thought the function should be in while condition. I took it different way I make two groups of romans numbers, because the princip is the same. without debbuger the return arr.map might be (e,i)=> numeral[i], because they are in order because you use join.