Hello. I want to submit a code stuff with an explanation. It is not a valid code. Someone can help me to find error?

<code>
** **

             I'm trying to build a program that change numbers writen in decimal notation.
             If we consider each ranges of numbers: unities, 10-es, 100-es and etc,
             the pattern is the same.
             If we take an array of characters ["a", "b", "c"], we have:
             1 --> 'a',
             2 --> 'aa',
             3- --> 'aaa'
             4 --> 'ab',
             5 --> 'b',
             6 --> 'ba',
             7 --> 'baa',
             8--> 'baaa',
             9-->'ac'.
             0 -->''
             Now we have as representations of abc:
             ('I', 'V', 'X');
             ('X', 'L', 'C');
             ('C', 'D', 'M');
             ('M', V with upperscore, X with upperscore ) and etc.
             The principe is the same, we need a strategy to replace the combinations
             of abc by the roman numeral symbols.
             I think that, e.g. if we take the number 257,
             The first step is to convert the number to string ‘257’.

            The second step is to slplit the string in an array
             var list = [‘2’, ‘5’, ‘7’]. his length is “l”.

            The third step is to looping through this array and replace
             the list [l-1] characters following the first representation of abc,
             the next, list [l-2] up to [0] replaced as this.

            the fourst step is to join the modified list with .join(‘’).
            You can see the Code and if you help me to debugging I'll be grateful!*/

            function hitboleloute(num){//1e parenthese
             // Create a bidimentionnal list that contain successives degree of a same
             // principle.
             var superlist = [["a", "I","X","C", "M"], ["b", 'V', 'L', "D"],
             ["c", "X", "C", "M"]]
            1.//the first step num to string.
            2.var letter1 = num.toString();
            3.
            4.//the second step string to array
            5.var letter3 = letter1.split('');
            6.var l = letter3.length;
            7.
            8.//the third step looping through array and replace digit-string by letter
            9.//of symbolic value.
            10.for(i = 0; i < l; i++ ) {// 2e parenthese
            11.    var item  = letter3[i];
            12.    if(item === '1') {item = 'a'}
            13.    else if (item === '2') {return "aa"}
            14.    else if (item === '3') {return "aaa"}
            15.    else if (item === '4') {return "ab"}
            16.    else if (item === '5') {return "b"}
            17.    else if (item === '6') {return "ba"}
            18.    else if (item === '7') {return "baa"}
            19.    else if (item === '8') {return "baaa"}
            20.    else if (item === '9') {return "ac"}
            21.    else if (item === '0') {return ""}
            22.}//2e parenthese closed
            23.// the letter3 array should be an array of symbolic letters
            24.console.log(letter3);
            25.// trying to replace a,b and c by realy roman numerals


            for (x = 0; x<4; x++){//new 2e parenthese

            for (j = l -x; j > -1; j --) {//3e parenthese
             var jtem = letter3[j];
             if (j == l-x) {for (k=0; k<item.length; k++) {//4e parenthese
             if (jtem[k] === 'a') {
             return superlist[0][x];
             }
             if (jtem[k] === 'b') {
             return superlist[1][x];
             }
             if (jtem[k] === 'c') {
             return superlist[2][x];
             }
             }//4e parenthese closed
             }//3e parenthese closed
             }//new 2e parenthese closed
             return jtem;
             }//1e parenthese closed
             // a list of roman numerals
             return letter3
             }
             hitboleloute(36);</code> 

First, did you see a mistake at the beginning? Your superlist variable is not initialized the way your algorithm is explaining. It could be var superlist = [["I", "V", "X"], ["X", "L", "C"], ["C", "D", "M"], ["M", "V&772;", "X&772;"]];.

Second, you are supposed to loop from the last character in the string (index l-1) all the way to the first (index 0). What you are doing is to loop from index 0 up to index l-1 which will give you a wrong result.

Third, your for loop through the string (line 49) should NOT RETURN a value but rather PUSH (if use reverse later on) or UNSHIFT the found letter into a result array which will be used in join() later on.

Last, the second and third for loops (line 67 & 69) are not needed if you do it correctly with the first for-loop. You should simply return a join("") value of the result array.

Hope this help.

Edited 1 Year Ago by Taywin

@Taywin Thank you very much. I need some explanations to understand your response.
Be patient with me...

Quoted Text irst, did you see a mistake at the beginning? Your superlist variable is not initialized the way your algorithm is explaining. It could be var superlist = [["I", "V", "X"], ["X", "L", "C"], ["C", "D", "M"], ["M", "V&772;", "X&772;"]];Here

I want to include a in the first item, 2 in the secund and c in the third. In this way, the last number e.g 3 of 123 will be aaa and next it is at the l-1 index of letter 3 and in superlist takes us in the index 1 of each item of the superlist (unity-> l -1 -> index 1) and in the ten's that are at index l-1 index l - 2 of the letter3 takes us at the index 2 of the items of superlist (tens -> l -2 -> index2). It why I entered abc at the index 0 of each item of superlist.

Second, you are supposed to loop from the last character in the string (index l-1) all the way to the first (index 0). What you are doing is to loop from index 0 up to index l-1 which will give you a wrong result.

the end of the array list 3 is for the unities. and for the unities I need the index I of the items of superlist. l-1of letter3 correspond to 1 of the items of superlist, l-2 to 2 and etc.

Last, the second and third for loops (line 67 & 69) are not needed if you do it correctly with the first for-loop. You should simply return a join("") value of the result array.

in the first loop I want to replace the abc model in IVX or XLC or CDM following her indexality. Without this step, the roman numbers are absents.
But you're right, the next step is with join. but the code was very voluminous and I see that my mistakes are before, so I removed it

Edited 1 Year Ago by kouty

// Create a bidimentionnal list that contain successives degree of a same
// principle.
    var superlist = [["a", "I","X","C", "M"], ["b", 'V', 'L', "D"],
    ["c", "X", "C", "M"]]

    //the first step num to string.
    var letter1 = num.toString();

    //the second step string to array
    var letter3 = letter1.split('');
    var l = letter3.length;

    //the third step looping through array and replace digit-string by letter
    //of symbolic value.
    for(i = 0; i < l; i++ ) {// 2e parenthese
        var item  = letter3[i];
        if(item === '1') {item = 'a'}
        else if (item === '2') {letter3.splice(i,1,"aa")}
        else if (item === '3') {letter3.splice(i,1,"aaa")}
        else if (item === '4') {letter3.splice(i,1,"ab")}
        else if (item === '5') {letter3.splice(i,1,"b")}
        else if (item === '6') {letter3.splice(i,1,"ba")}
        else if (item === '7') {letter3.splice(i,1,"baa")}
        else if (item === '8') {letter3.splice(i,1,"baaa")}
        else if (item === '9') {letter3.splice(i,1,"ac")}
        else if (item === '0') {letter3.splice(i,1)}
    }//2e parenthese closed
       for (x = 0; x<4; x++){//new 2e parenthese
 for (j = l -x; j > -1; j --) {//3e parenthese
    var jtem = letter3[j].split('');
    if (j == l-x) {for (k=0; k<jtem.length; k++) {//4e parenthese
        if (jtem[k] === 'a') {
             jtem.splice(k,1,superlist[0][x]).join('');
        }
        if (jtem[k] === 'b') {
             jtem.splice(k,1,superlist[1][x]).join('');
        }
        if (jtem[k] === 'c') {
             jtem.splice(k,1,superlist[2][x]).join('');
        }
    }//4e parenthese closed
  }//3e parenthese closed
}//new 2e parenthese closed

}//1e parenthese closed
// a list of roman numerals
return letter3.join('');
}
hitboleloute(2222);

It return in repl.it

Native Mozilla Firefox JavaScript.
Copyright (c) 2013 Mozilla Foundation



TypeError: letter3[j] is undefined

What's wrong? I defined jtem as a variable that may be an array and letter3[j] is an item of this array.
@Taywin. instead of push I replaced the "returns" with splicing.

Edited 1 Year Ago by kouty

@Taywin

 // Create a bidimentionnal list that contain successives degree of a same
    // principle.
        var superlist = [["a", "I","X","C", "M"], ["b", 'V', 'L', "D"],
        ["c", "X", "C", "M"]]

        //the first step num to string.
        var letter1 = num.toString();

        //the second step string to array
        var letter3 = letter1.split('');
        var l = letter3.length;

        //the third step looping through array and replace digit-string by letter
        //of symbolic value.
        for(i = 0; i < l; i++ ) {// 2e parenthese
            var item  = letter3[i];
            if(item === '1') {item = 'a'}
            else if (item === '2') {letter3.splice(i,1,"aa")}
            else if (item === '3') {letter3.splice(i,1,"aaa")}
            else if (item === '4') {letter3.splice(i,1,"ab")}
            else if (item === '5') {letter3.splice(i,1,"b")}
            else if (item === '6') {letter3.splice(i,1,"ba")}
            else if (item === '7') {letter3.splice(i,1,"baa")}
            else if (item === '8') {letter3.splice(i,1,"baaa")}
            else if (item === '9') {letter3.splice(i,1,"ac")}
            else if (item === '0') {letter3.splice(i,1)}
        }//2e parenthese closed
           for (x = 0; x<4; x++){//new 2e parenthese
     for (j = l -x; j > -1; j --) {//3e parenthese
        var jtem = letter3[j].split('');
        if (j == l-x) {for (k=0; k<jtem.length; k++) {//4e parenthese
            if (jtem[k] === 'a') {
                 jtem.splice(k,1,superlist[0][x]).join('');
            }
            if (jtem[k] === 'b') {
                 jtem.splice(k,1,superlist[1][x]).join('');
            }
            if (jtem[k] === 'c') {
                 jtem.splice(k,1,superlist[2][x]).join('');
            }
        }//4e parenthese closed
      }//3e parenthese closed
    }//new 2e parenthese closed

    }//1e parenthese closed
    // a list of roman numerals
    return letter3.join('');
    }
    hitboleloute(2222);

It return in repl.it

Native Mozilla Firefox JavaScript.
Copyright (c) 2013 Mozilla Foundation



TypeError: letter3[j] is undefined

What's wrong? I defined jtem as a variable that may be an array and letter3[j] is an item of this array.
@Taywin. instead of push I replaced the "returns" with splicing.

Edited 1 Year Ago by kouty

OK. It is not wrong to have bloated the code. I just tried to guide you to follow the written algorithm. It needs practice to be able to understand what the algorithm is talking about. You are doing well until you hit the core part of the function (where you need to replace the digit with letters).

Anyway, when you want to "replace" the value inside your result array, you could "hard-code" the representation in this case because there is NO CHANGE in the way it works. This would make the function more readable. You would see how short it becomes.

Below is what I revise your function with more obvious variable names, but it is incomplete. You have to complete the core part of the function.

// The function assumes that the input is ALWAYS valid (1 ~ 9999)
// If the incoming value is more than 4 digits, it will BREAK!
function hitboleloute(num) {
  // delcare the replacement list
  var superlist = [["I", "V", "X"], ["X", "L", "C"], ["C", "D", "M"], ["M", "V&#772;", "X&#772;"]];

  //the first step num to string.
  var letter1 = num.toString();

  //the second step string to array
  var results = letter1.split('');  // <-- changed name from 'letter3' for clarity
  var l = results.length;
  var sl = 0;    // <-- start from least significant digit in superlist

  // the third step, looping through array & replace/match the digit with letters
  for (var digit=l-1; digit>=0; digit--) {
    var item = results[digit]; // retrieve the digit

    /*
    when sl=0, list is ["I", "V", "X"]
    when sl=1, list is ["X", "L", "C"]
    when sl=2, list is ["C", "D", "M"]
    when sl=3, list is ["M", "V&#772;", "X&#772;"]
    */
    var list = superlist[sl];  // <-- retrieve the list corresponding to its digit

    // [[[ CORE PART ]]]
    // replacing with representative "a" [hard-code]
    //   which is list[0] or the 1st item in the list
    if (item=="1") { results[digit] = list[0]; }  
    // replacing with representative "aa" [hard-code]
    //   which is list[0]+list[0]
    else if (item=="2") { results[digit] = list[0]+list[0]; }
    ...
    else if (item=="9") { ... }
    else { results[digit] = ""; }  // by default, it is empty
    sl =+ 1;  // increase the index for superlist look up
  }

  // the forth step, join the list & return the value
  // the value inside join() is the delimiter
  // if leave it empty, by default, the value is ","
  return results.join("");
}

If you still have any question, please ask.

Edited 1 Year Ago by Taywin

@Taywin: A very good lesson for me.
First, Thank's so much!
I will study your explanations and come back.
One (not only) thing is mysterious for me: The change of attribute don't work.
for example
function exchange(num) {if (num ==='a') { num = 'V';}return num;}

And if I make
var a = 4; a = 5; console.log(a) //=>5.works.
So: else if (item === '8') {letter3.splice(i,1,"baaa")} can be replaced by if (item ==='8') {item ='baaa';}. Isn't?
and
if (jtem[k] === 'b') { jtem[k] = superlist[1][x];} is good too?
for example in this way we can modifie values in arrays without splice method. And to modify string by if (word.charAt(k) === 'b' {word.charAt(k) = 'V'}. Is it true?

How is it that it is not constructed following the same mechanism?

@administrator, the mails from Daniweb falls in the "Bulk Mail" cathegory in the yahoo&thunderbird messagerie. Why?

Edited 1 Year Ago by kouty: courtesy

This problem is hard coz' you need to find common denominators in decimal input with Roman Numerals as common factors. Then you output that Roman Numeral, subtract it with decimal input. Keep doing this until 0 decimal inputs are left. Outputing Roman Numeral is ofcourse parsing int from gcd() to { 'L', 'M', 'X', 'V', 'I' }.

int gcd(int p, int q)
{
    while(p % q != 0)
    {
        int r = p % q;
        p = q; q = r;
    }
    return q;
}

So given any decimal number, one can gcd() the Roman Numeral factors and output the corresponding Roman number.

I would like to add the occurance of Prime Numbers which is only divisible by itself and 1. Be prepared to output such numbers with Roman Numerals... :(

Edited 1 Year Ago by マーズ maazu

@maazu
The problem is not hard at all because there is a specified algorithm for you. You do not need to use gcd() at all but follow the algorithm. Parts of the algorithm are supposed to be hard-coded which is acceptable in this case. There is no need to make it dynamic or attempt to accept all types of inputs. This is just a practice problem which expects valid inputs.

@kouty
The function won't work because the function accepts only 1 argument. It doesn't know which sublist it is working on. You would need 2 arguments for the function -- num and list. The num is the letter you want, and the list is the sublist you are working on regarding the working digit. See the sample below

// a is index 0, b is index 1, and c is index 2
function exchange(num, list) {
    if (num=='a') { num = list[0]; }
    else if (num=='aa') { num = list[0]+list[0]; }
    ...
    return num;
 }

Hmm... I am not sure about this else if (item === '8') {letter3.splice(i,1,"baaa")} can be replaced by if (item ==='8') {item ='baaa';} question. Why would you need to splice an array when you actually need to iterate inside the array? Also, the former is to replace a value inside the array (but in an inefficient way and is harder to maintain) but the latter is simply replace the variable value. They are 2 different assignments.

The if (jtem[k] === 'b') { jtem[k] = superlist[1][x];} may be correct but I don't know what x is and if and only if you are working on the 2nd least significant digit of the input num.

No, the (word.charAt(k) === 'b' {word.charAt(k) = 'V'} won't change the value of word.charAt(k) because the function charAt() is not a modifier function. You can't assign a value to it.

PS: You should not use === in your current comparison. It is more strict than using ==; besides, you are not comparing object to object but rather value to value. Please be careful when do the comparison. ;)

Edited 1 Year Ago by Taywin

@Taywin Good, can I ask still 1 question. What's new Today with the for loops: A new mystere!?

function hitboleloute(num) {//1e parenthese
// Create a bidimentionnal list that contain successives degree of a same
// principle.
    "use strict";
    var superlist = [["a", "I", "X", "C", "M"], ["b", 'V', 'L', "D"],
            ["c", "X", "C", "M"]];

    //the first step num to string.
    var letter1 = num.toString();
    console.log("la premiere operation sur le nombre: ", letter1);
    //the second step string to array
    var letter2 = letter1.split('');
    var l = letter2.length;
    console.log("premiere apparition de letter2 ", letter2);//!1e affiche

    //the third step looping through array and replace digit-string by letter
    //of symbolic value.
    function exchange(array, val1, val2)  {array[array.indexOf(val1)] = val2;
        return array;
    }
    for(var i = 0; i < l; i++ ) {// 2e parenthese
        var item  = letter2[i];
        console.log("item avant d'etre transforme ", item);
        if(item === '1') {exchange(letter2,'1', 'a')}
        else if (item === '2') {exchange(letter2, '2', 'aa'); console.log("premier changement ", item)}
        else if (item === '3') {exchange(letter2,'3', "aaa")}
        else if (item === '4') {exchange(letter2, '4', "ab")}
        else if (item === '5') {exchange(letter2,'5', "b")}
        else if (item === '6') {exchange(letter2,'6',"ba")}
        else if (item === '7') {exchange(letter2,'7', "baa")}
        else if (item === '8') {exchange(letter2,'8', "baaa")}
        else if (item === '9') {exchange(letter2,'9', "ac")}
        else {exchange(item,'0', '')}
        console.log("item ", item);
        console.log("letter2 apres chaque tour ",letter2);
    }//2e parenthese closed
    function changeLetters(mot, a, b) {
        mot[mot.indexOf(a)] = b;
    }
       for (var n = 0; n<4; n++) {//new 2e parenthese

       for (var j = l -n; j > -1; j --) {//3e parenthese
           var jtem = letter2[j];//chaque jtem est un mot de 3 lettres.

               //si l'index de ce mot est l - x, on va puiser les
               //remplacents dans l'element numerote x de la superliste
           //4e parenthese
          if (jtem !==null && jtem!== undefined && jtem.charAt(n) === 'a') {
             changeLetters(jtem,'a', superlist[0][n]);
             console.log(jtem);
        }
         else if (jtem !==null && jtem!== undefined && jtem.charAt(n) === 'b') {
             changeLetters(jtem, 'b', superlist[1][x]);
             console.log(jtem);
        }
        else if (jtem !==null && jtem!== undefined && jtem.charAt(n) === 'c') {
             changeLetters(jtem, 'c', superlist[2][n]);
    }//4e parenthese closed
  }//3e parenthese closed
}//new 2e parenthese closed

//1e parenthese closed
// a list of roman numerals
return letter2.join('');
}
hitboleloute(124);

The output is

la premiere operation sur le nombre:  124
premiere apparition de letter2  [ '1', '2', '4' ]
item avant d'etre transforme  1
item  1
letter2 apres chaque tour  [ 'a', '2', '4' ]
item avant d'etre transforme  2
premier changement  2
item  2
letter2 apres chaque tour  [ 'a', 'aa', '4' ]
item avant d'etre transforme  4
item  4
letter2 apres chaque tour  [ 'a', 'aa', 'ab' ]
TypeError: 0 is read-only

if i modify the for loop with (n = 0;...etc) instead (var n = 0... etc) the output is
ReferenceError: assignment to undeclared variable n
At the end more I try less I understand,.... How many is 1 + 1?

@Taywin
Here is the last effort.

function changeLetters(array, a, b) {
    array[a] = b;
    return array;
    }

function hitboleloute(num) {//1e parenthese
// Create a bidimentionnal list that contain successives degree of a same
// principle.
    "use strict";
    var superlist = [["a", "I", "X", "C", "M"], ["b", 'V', 'L', "D"],
            ["c", "X", "C", "M"]];

    //the first step num to string.
    var letter1 = num.toString();
    console.log("la premiere operation sur le nombre: ", letter1, '\n');
    //the second step string to array
    var letter2 = letter1.split('');
    var l = letter2.length;
    console.log("premiere apparition de letter2 ", letter2, '\n');//!1e affiche

    //the third step looping through array and replace digit-string by letter
    //of symbolic value.

    for(var i = 0; i < l; i++ ) {// 2e parenthese
        var item  = letter2[i];
        console.log("item avant d'etre transforme ", item, '\n');
        if(item === '1') {changeLetters(letter2,i, 'a')}
        else if (item === '2') {changeLetters(letter2, i, 'aa');}
        else if (item === '3') {changeLetters(letter2,i, "aaa")}
        else if (item === '4') {changeLetters(letter2, i, "ab")}
        else if (item === '5') {changeLetters(letter2,i, "b")}
        else if (item === '6') {changeLetters(letter2,i,"ba")}
        else if (item === '7') {changeLetters(letter2,i, "baa")}
        else if (item === '8') {changeLetters(letter2,i, "baaa")}
        else if (item === '9') {changeLetters(letter2,i, "ac")}
        else {changeLetters(item,i, '')}
            }// 2e parenthese closed
    console.log("letter2 apres la fin de la boucle ", letter2, '\n');
    for (var u = 0; u < letter2.length; u++) {//new 2e parenthese
        letter2[u] = letter2[u].split('');}//new 2e parenthese closed
    console.log("letter2 double listee: ", letter2);
    //2e parenthese closed

    //le premier for est pour passer les elements de letter2
        for (var j = l -1; j > -1; j --) {//new 2e parenthese
            var jtem = letter2[j];
            for (var n = jtem.length - 1; n > -1 ; n--) {//3e parenthese   


                if(jtem !==null && jtem!== undefined) {//4e parenthese
           //chaque jtem est un mot de 3 lettres.

               //si l'index de ce mot est l - x, on va puiser les
               //remplacents dans l'element numerote x de la superliste

                    if (jtem[n] === 'a') {// 5e parenthese
                        changeLetters(jtem, n, (superlist[n])[1]);
                        console.log("jtem", jtem, '\n');

                        }// 5e parenthese closed
                    else if (jtem[n] === 'b') {
                        changeLetters(jtem, n, (superlist[n])[2]);
                        console.log("jtem", jtem, '\n');

                        }
                    else if (jtem[n] === 'c') {
                        changeLetters(jtem, n, (superlist[n])[3]);
                        console.log("jtem", jtem, '\n');


                        }//5e parenthese closed
                    }//4e parenthese closed
                }//new 3e parenthese closed
            }//2e parenthese closed
            jtem = jtem.join('');
        // a list of roman numerals
        return letter2.join('');
    }//1e parenthese closed
hitboleloute(36);

But malencontrously the result is ... wrong!

The last effort.

function changeLetters(array, a, b) {
    array[a] = b;
    return array;
    }
function hitboleloute(num) {//1e parenthese
// Create a bidimentionnal list that contain successives degree of a same
// principle.
    "use strict";
    var superlist = [["a", "I", "X", "C", "M"], ["b", 'V', 'L', "D"],
            ["c", "X", "C", "M"]];
    //the first step num to string.
    var letter1 = num.toString();
    //the second step string to array
    var letter2 = letter1.split('');
    var l = letter2.length;
    //the third step looping through array and replace digit-string by letter
    //of symbolic value.
    for(var i = 0; i < l; i++ ) {// 2e parenthese
        var item  = letter2[i];
        if(item === '1') {changeLetters(letter2,i, 'a')}
        else if (item === '2') {changeLetters(letter2, i, 'aa');}
        else if (item === '3') {changeLetters(letter2,i, "aaa")}
        else if (item === '4') {changeLetters(letter2, i, "ab")}
        else if (item === '5') {changeLetters(letter2,i, "b")}
        else if (item === '6') {changeLetters(letter2,i,"ba")}
        else if (item === '7') {changeLetters(letter2,i, "baa")}
        else if (item === '8') {changeLetters(letter2,i, "baaa")}
        else if (item === '9') {changeLetters(letter2,i, "ac")}
        else {changeLetters(item,i, '')}
            }// 2e parenthese closed
    for (var u = 0; u < letter2.length; u++) {//new 2e parenthese
        letter2[u] = letter2[u].split('');}//new 2e parenthese closed
    //2e parenthese closed
    //le premier for est pour passer les elements de letter2
        for (var j = l -1; j > -1; j --) {//new 2e parenthese
            var jtem = letter2[j];
            var ll = jtem.length;
            for (var n = ll - 1; n > -1 ; n--) {//3e parenthese
                if(jtem !==null && jtem!== undefined) {//4e parenthese
           //chaque jtem est une liste de 3 lettres.
               //si l'index de ce mot est l - x, on va puiser les
               //remplacents dans l'element numerote x de la superliste
                    if (jtem[n] === 'a') {// 5e parenthese
                        changeLetters(jtem, n, (superlist[0])[ll - n]);
                        }// 5e parenthese closed
                    else if (jtem[n] === 'b') {
                        changeLetters(jtem, n, (superlist[1])[ll - n]);
                        }
                    else if (jtem[n] === 'c') {
                        changeLetters(jtem, n, (superlist[2])[ll - n]);
                        }//5e parenthese closed
                    }//4e parenthese closed
                }//new 3e parenthese closed
            }//2e parenthese closed
            jtem = jtem.join('');
        // a list of roman numerals
        return letter2.join('');
    }//1e parenthese closed
hitboleloute(36);

@Taywin Thanks to you!!!!!!!!!!!

function changeLetters(array, a, b) {
    array[a] = b;
    return array;
    }
function hitboleloute(num) {
    "use strict";
    var superlist = [["a", "I", "X", "C", "M"], ["b", 'V', 'L', "D"],
            ["c", "X", "C", "M"]];
    var letter1 = num.toString();
    console.log("ligne 15 ", letter1);
    console.log("ligne 16 la premiere operation sur le nombre: ", letter1, '\n');
    var letter2 = letter1.split('');
    var l = letter2.length;
    console.log("ligne 20 premiere apparition de letter2 ", letter2, '\n');
    for(var i = 0; i < l; i++ ) {
        var item  = letter2[i];
        console.log("ligne 27 item avant d'etre transforme ", item, '\n');
        if(item === '1') {changeLetters(letter2,i, 'a')}
        else if (item === '2') {changeLetters(letter2, i, 'aa');}
        else if (item === '3') {changeLetters(letter2,i, "aaa")}
        else if (item === '4') {changeLetters(letter2, i, "ab")}
        else if (item === '5') {changeLetters(letter2,i, "b")}
        else if (item === '6') {changeLetters(letter2,i,"ba")}
        else if (item === '7') {changeLetters(letter2,i, "baa")}
        else if (item === '8') {changeLetters(letter2,i, "baaa")}
        else if (item === '9') {changeLetters(letter2,i, "ac")}
        else {changeLetters(item, i, '')}
            }
    console.log("lign 39 letter2 apres la fin de la boucle ", letter2, '\n');
    for (var u = 0; u < letter2.length; u++) {
        letter2[u] = letter2[u].split('');}
    console.log("ligne 42 letter2 double listee: ", letter2);
            for (var j = l -1; j > -1; j --) {
            var jtem = letter2[j];
            var ll = jtem.length;
            console.log("ligne 49, jtem et ll", jtem, ll);
            for (var n = 0; n < ll ; n++) {     
                    if (jtem[n] === 'a') {// 5e parenthese
                        changeLetters(jtem, n, (superlist[0])[l - j]);
                        console.log("ligne 61 jtem", jtem, '\n');                      
                        }
                    else if (jtem[n] === 'b') {
                        changeLetters(jtem, n, (superlist[1])[l - j]);
                        console.log("ligne 66 jtem", jtem, '\n');                        
                        }
                    else if (jtem[n] === 'c') {
                        changeLetters(jtem, n, (superlist[2])[l - j]);
                        console.log("ligne 71 jtem", jtem, '\n');                       
                                     }
                }
            }
            jtem = jtem.join("");
              letter2 = letter2.join("")
        return letter2.replace(/,/g,"");
    }hitboleloute(36);

It is GOOOOOOOOOOOOD!!!!!!!!!!!!!!!!!!!

@Taywin
"No, the (word.charAt(k) === 'b' {word.charAt(k) = 'V'} won't change the value of word.charAt(k) because the function charAt() is not a modifier function. You can't assign a value to it.,,
charA can not atribute, it describ and search. Very important. Thank's It is not as in Python a difference between strings and arrays. e.g. replacing by indexation is possible?

That is the end of this question. Thank's to Daniweb

This question has already been answered. Start a new discussion instead.