Roman numerial converter -solved

function convertToRoman(num) {

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

so my question is what would be better in programing sence? this code or if the code was with a nested while instead of the if?

Can refer to my demo, I hope to help you!
ConvertMoman