Roman Numeral conversion problem

I dont understand the while loop here. when num = 2, the decimalValue[0] = 1000. and the decimalValue[index] <=2 wont be satisfied. At least, its what i think. Please help

Your code so far


function convertToRoman(num) {
let decimalValue = [1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1];
let romanNumeral = ["M","CM","D","CD","C","XC","L","XL","X","IX","V","IV","I"];

let romanized = "";

for(let index = 0; index < decimalValue.length; index++)
{
  while(decimalValue[index] <= num)
  {
   romanized += romanNumeral[index];
   num-= decimalValue[index];
  }
}
return romanized;
}

convertToRoman(36);

Your browser information:

User Agent is: Mozilla/5.0 (Linux; Android 10; SM-A205YN) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.127 Mobile Safari/537.36.

Challenge: Roman Numeral Converter

Link to the challenge:

Yes. That’s why the while stops.
Then you are back in the for, where the index gets increased (index++).
Now you are at decimalValue[1].

It’s true…
In the testcase when num = 36, while loop will start executing when decimalValue[index]<=36 (i.e. index=8, decimalValue[8]=10)