is there a way to refactoring this to make it more “efficient”.
or it would be needed to be done with map method to it be better?
sorry i started 2 weeks ago , and im still getting used to the “programmer mindset” (^.^)b
Thanks
Your code so far
function convertToRoman(num) {
let mil = '',valM =[['M'],['MM'],['MMM'],['MMMM']], resM=Math.floor(num/1000);
let cen = '',valC =[['C'],['CC'],['CCC'],['CD'],['D'],['DC'],['DCC'],['DCCC'],['CM']], resC=Math.floor((num/100)-(resM*10));
let dec = '',valD =[['X'],['XX'],['XXX'],['XL'],['L'],['LX'],['LXX'],['LXXX'],['XC']], resD=Math.floor((num/10)-(resC*10)-(resM*100));
let uni = '',valU =[['I'],['II'],['III'],['IV'],['V'],['VI'],['VII'],['VIII'],['IX']], resU=Math.floor((num/1)-(resD*10)-(resC*100)-(resM*1000));
if (resM != 0){ for(let i =0 ; i<resM ;i++) {mil = valM[i] ;} }
if (resC != 0){ for(let i =0 ; i<resC ;i++) {cen = valC[i] ;} }
if (resD != 0){ for(let i =0 ; i<resD ;i++) {dec = valD[i] ;} }
if (resU != 0){ for(let i =0 ; i<resU ;i++) {uni = valU[i] ;} }
let result = mil + cen + dec + uni ;
return result;
}
convertToRoman(3999);```
**Your browser information:**
Your Browser User Agent is: ```Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36 OPR/52.0.2871.64```.
**Link to the challenge:**
https://www.freecodecamp.org/challenges/roman-numeral-converter