# Some opnion and idead about my roman number conver upto 4000 ..i love solving my way

``````let myobjtest={1:"I",5:"V",10:"X",50:"L",100:"C",500:"D",1000:"M" };
//check romanthousand and fix;
function convertToRoman(gvnnum) {

if(gvnnum<=10){return romanupten(gvnnum);}
if (gvnnum<=50){return romantenuptofifity(gvnnum);}
if (gvnnum<=100){return romanuphundred(gvnnum)}
if(gvnnum<=500){return romanfivehundred(gvnnum);}
if(gvnnum<=1000){return romanthousand(gvnnum);}
if(gvnnum<=3999){return romanuptofourthousand(gvnnum);}
}

function romanupten(num)
{
return num<=3?concatroman(myobjtest[1],num):num<=4?myobjtest[1]+myobjtest[5].toString():num===5?myobjtest[5]:num<=8?myobjtest[5]+concatroman(myobjtest[1],num-5):num===9?myobjtest[1]+myobjtest[10]:num===10?myobjtest[10]:undefined
}

function romantenuptofifity(num){
return num<=19?myobjtest[10]+romanupten(num-10):num<=39?concatroman(myobjtest[10],parseInt(num.toString()[0]))+romanupten(parseInt(num.toString()[1])):num<=49?myobjtest[10]+myobjtest[50]+romanupten(parseInt(num.toString()[1])):num===50?myobjtest[50]:undefined
}
function romanuphundred(num){
return num<=89?myobjtest[50]+concatroman(myobjtest[10],parseInt(num.toString()[0]-5))+romanupten(parseInt(num.toString()[1])):num<=99?myobjtest[10]+myobjtest[100]+romanupten(parseInt(num.toString()[1])):num===100?myobjtest[100]:undefined
}
function romanfivehundred(num){
return num<=399?concatroman(myobjtest[100],parseInt(num.toString()[0]))+findd(parseInt(num.toString()[1]+num.toString()[2])):num<500?myobjtest[100]+myobjtest[500]+findd(parseInt(num.toString()[1]+num.toString()[2])):num===500?myobjtest[500]:undefined;
}
function romanthousand(num){
return num<=599?myobjtest[500]+findd(parseInt(num.toString()[1]+num.toString()[2])):num<=899?myobjtest[500]+concatroman(myobjtest[100],parseInt(num.toString()[0]-5))+findd(parseInt(num.toString()[1]+num.toString()[2])):num<=999?myobjtest[100]+myobjtest[1000]+findd(parseInt(num.toString()[1]+num.toString()[2])):num===1000?myobjtest[1000]:undefined

}
function romanuptofourthousand(num){
return num<=3999?concatroman(myobjtest[1000],parseInt(num.toString()[0]))+findd(parseInt(num.toString()[1]+num.toString()[2]+num.toString()[3])):undefined
}

function findd(num){

if(num<=10){return romanupten(num)};
//if(num>50){ return romanuphundred(num)};
if(num<=50) {
return romantenuptofifity(num);}

if(num<=100){return romanuphundred(num)};
if(num<=500){return romanfivehundred(num)}
if(num<=1000){return romanthousand(num)}
}
function concatroman(num,time){
let hold="";
while(time>0){
hold=hold+num;
time--;
}
return hold
}

convertToRoman(36);
``````