# Help with: JavaScript Algorithms and Data Structures Projects: Roman Numeral Converter

So, the solution I thought up for this challenge was to get two arrays (one with the Roman Numerals and the other with the Decimals), join key:value together and then just look up the “num” variable. It works, but, of course, it only works if I get every value possible in both arrays which seems to go agaisnt the nature of the challenge (not to mention agaisnt any actual functionality). Any ideas on how I could improve it?

``````var arrRoman=["I","IV","V","IX","X","XL","L","C","D","M"];
var arrNumbers=[1,4,5,9,10,40,50,100,500,1000];
var comparison= {};
for (var i = 0; i < arrRoman.length; i++)
comparison[arrNumbers[i]] = arrRoman[i];
return (comparison[num]);
}

convertToRoman(36);``````

I would consider using a `while` loop and either count down from your number to 0, or up from 0 to your number

1 Like

That sounds promising, thank you for the input. The only issue I see with that is that I would have to implement a lot of rules for non-linear numbers (like 4=IV, etc).