# Roman Numeral Converter Short way

I completed the Roman Numeral Converted. However, I’m still wondering if there is a short way to call the Roman Numbers like with the Binary numbers? I did my best with the code, however, I still have the big Object “Codes”

function convertToRoman(num) {

var Codes = [["","I","II","III","IV","V","VI","VII","VIII","IX"],["","X","XX","XXX", "XL", "L", "LX", "LXX", "LXXX", "XC"],["","C","CC","CCC","CD","D","DC","DCC","DCCC","CM",],  ["","M","MM","MMM"]];

return(num.toString().split("").reverse().map((x,y)=>Codes[y++][x]).reverse().join(""))

}

convertToRoman(2620);

My solution is a bit larger.

function convertToRoman(num) {
let dict = {
1: “I”,
5: “V”,
10: “X”,
50: “L”,
100: “C”,
500: “D”,
1000: “M”
};
return num.toString().split("").map((x, i, a) => {
let pref = Math.pow(10, a.length - i - 1);
return Number(x) < 4 ? dict[pref].repeat(Number(x)) :
Number(x) === 4 ? dict[pref] + dict[5 * pref] :
Number(x) > 4 && Number(x) < 9 ? dict[5 * pref] + dict[pref].repeat(Number(x) - 5) :
dict[pref].repeat(10 - Number(x)) + dict[10 * pref]
})
.join("");
}