How do you convert a number to a roman numeral?
#javascript #conversion #romannumeral
***SAMPLE FUNCTION:
function roman(num){
let rom =
{M:1000,CM:900, D:500,CD:400,
C:100,XC:90,L:50,XL:40,X:10,IX:9,
V:5,IV:4,I:1 }
let output = '';
while(num greater than symbol 0){
for(a in rom){
if(rom[a] less than, equal to symbol num)
{output += a; num-=rom[a]; break;}
}
}
console.log(output)
return output;
}
roman(49); // XLIX
roman(10); // X
roman(3); // III