Roman Numeral Converter - counter problem

Tell us what’s happening:

i am trying to move from one conditional statement to another but it wont proceed from the first stage to the next conditional statement

Your code so far


function convertToRoman(num) {
  let rom =""
  for (var i=num; i>=0; ){
    if (i >= 10 && i <40){ 
    rom += "X";
    i-=10
    console.log(i)
    if(i === 9){
     rom += "IX";
     i-=9;
     console.log(rom)
      if (i<9 && i>6){
     rom += "I"
     i-=1;
     console.log(i)
     if(i===5){
     rom += "V";
     i-=5;
   }
   if(i === 4){
     rom += "IV";
     i-=4;
     if (i <= 3 ){
     rom += "I";
     i-=1
   }
   }
   
   }
   
   }
  
   }
   
  }

 return rom
}

convertToRoman(36);

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/javascript-algorithms-and-data-structures-projects/roman-numeral-converter

With test case 36. Your loop reaches until 3rd nested if statements. Variable i becomes 6 then it goes back from the start of the forloop with that value. Then what? There is no condition to check for 6. Then it goes on infinitely.

I would restructure this and not put multiple if statements nested in if statements.

Thank you i had to start all over again and i used while() instead of for () and now it worked although i removed the nested if statements.