# Recursive function broke the Roman Numbers challenge

Recursive function broke the Roman Numbers challenge
0

#1

Hi I used this code and now I can’t do the challenge anymore, everytime I open the challenge the screen freeze, I think is maybe an infinite loop.
Someone knows how to reset this, thank you!

``````function convertToRoman(num) {
var result = "";
var romanArr = [
[1000, "M"],
[900, "CM"],
[500, "D"],
[400, "CD"],
[100, "C"],
[90, "XC"],
[50, "L"],
[40, "XL"],
[10, "X"],
[9, "IX"],
[5, "V"],
[4, "IV"],
[1, "I"]
];
for(var i = 0; i < romanArr.length; i++){
if(num >= romanArr[i][0]){
result += romanArr[i][1] + convertToRoman(num - romanArr[i][0]);
}
}
return result;
}
convertToRoman(36)
``````

with this was working

``````function convertToRoman(num) {
var result = "";
var romanArr = [
[1000, "M"],
[900, "CM"],
[500, "D"],
[400, "CD"],
[100, "C"],
[90, "XC"],
[50, "L"],
[40, "XL"],
[10, "X"],
[9, "IX"],
[5, "V"],
[4, "IV"],
[1, "I"]
];
for(var i = 0; i < romanArr.length; i++){
if(num >= romanArr[i][0]){
return result += romanArr[i][1] + convertToRoman(num - romanArr[i][0]);
}
}

}
convertToRoman(36)
``````

#2

You have created infinite recursion.
FCC uses an infinite loop protection, but it can’t catch every case.
The reason that your browser crashes every time you try to load the challenge is because the code in your editor automatically runs. Try disabling auto run.
Another option is to clear the challenge data from your browser cache.

#3

Thank you, now is working, I remove the cookies and now is working