I don''t understand working of solution here

Tell us what’s happening:
Inside for loop the variable numerals = IIIIII at i=0, after that they have used replacing, I understand when it goes inside if IIIIII changes to VI, after that i don’t understand anything.
Can anyone help me with what those two replace function doing ?

Your code so far

function convertToRoman(num) {

let romanArr=[["I","II","III","IV","V","VI","VII","VIII","IX"],["X","XX","XXX","XL","L","LX","LXX","LXXX","XC"],["C","CC","CCC","CD","D","DC","DCC","DCCC","CM"],["M","MM","MMM"]];
let romanNumeral="";
let strNum=num.toString();
let count=0;
let replaceFromArr;
for(let i=strNum.length-1;i>=0;i--){
           let romanStr=romanArr[count][replaceFromArr-1]
return romanNumeral;


Your browser information:

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

Challenge: Roman Numeral Converter

Link to the challenge:

There is no variable with such name

That’s not what happens

There is no replace functions in the code

I think you need to work on focusing on things you see…

1 Like

Ohh i am so so sorrry, i pasted my soultion here. I wanted to understand the solution under get HInts tab

function convertToRoman(num) {
  var romans = [
      // 10^i 10^i*5
      ["I", "V"], // 10^0
      ["X", "L"], // 10^1
      ["C", "D"], // 10^2
      ["M"] // 10^3
    digits = num
      .map(function(item, index) {
        return parseInt(item);
    numeral = "";

  // Loop through each digit, starting with the ones place
  for (var i = 0; i < digits.length; i++) {
    // Make a Roman numeral that ignores 5-multiples and shortening rules
    numeral = romans[i][0].repeat(digits[i]) + numeral;
    // Check for a Roman numeral 5-multiple version
    if (romans[i][1]) {
      numeral = numeral
        // Change occurrences of 5 * 10^i to the corresponding 5-multiple Roman numeral
        .replace(romans[i][0].repeat(5), romans[i][1])
        // Shorten occurrences of 9 * 10^i
          romans[i][1] + romans[i][0].repeat(4),
          romans[i][0] + romans[i + 1][0]
        // Shorten occurrences of 4 * 10^i
        .replace(romans[i][0].repeat(4), romans[i][0] + romans[i][1]);

  return numeral;

// test here

Here the question, i was asking about this thank you

what do you not understand of this? the comments explain well what’s happening

I understand it now i tried python tutuor for it. Thanks