Tell us what’s happening:
Describe your issue in detail here.
My code getting the error of “return string” although I am returning a string!!!
let count=1;
const oneToNine={0:"",1:"I",2:"II",3:"III",4:"IV",5:"V",6:"VI",7:"VII",8:"VII",9:"IX"};
const tenToHun={10:"X",20:"XX",30:"XXX",40:"XL",50:"L",60:"LX",70:"LXX",80:"LXX",90:"XC"
}
const hunToThu={100:"C",200:"CC",300:"CCC",400:"CD",500:"D",600:"DC",700:"DCC",800:"DCCC",900:"CM"
}
function romanConvert(num2){
num2=num2*count;
count=count*10;
if(num2<10){
return oneToNine[num2];
}else if(num2>=10 && num2<100){
return tenToHun[num2];
}else if(num2>=100 && num2<1000){
return hunToThu[num2];
}else if(num2===1000) return "M";
else if(num2>1000){
let n=num2/1000;
let rom="";
for(let i=0;i<n;i++){
rom="M"+rom;
}
return rom;
}
}
function convertToRoman(num) {
let result="";
let num1=num;
while(num1!=0){
let rem=num1%10;
num1=Math.floor(num1/10);
result=romanConvert(rem)+result;
}
console.log(result);
return result;
}
convertToRoman(29);
**Your browser information:**
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36
Challenge: Roman Numeral Converter
Link to the challenge: