[javascript] Convert a number into a Roman Numeral in javaScript

Here is my code,Hope this helpful:

_x000D_
_x000D_
function convertToRoman(num) {_x000D_
    let numArr = [];//[M,D,C,L,X,V,I]_x000D_
    let numStr = "";_x000D_
_x000D_
    //get num Array_x000D_
    numArr.push(parseInt(num / 1000));_x000D_
    num %= 1000;_x000D_
    numArr.push(parseInt(num / 500));_x000D_
    num %= 500;_x000D_
    numArr.push(parseInt(num / 100));_x000D_
    num %= 100;_x000D_
    numArr.push(parseInt(num / 50));_x000D_
    num %= 50;_x000D_
    numArr.push(parseInt(num / 10));_x000D_
    num %= 10;_x000D_
    numArr.push(parseInt(num / 5));_x000D_
    num %= 5;_x000D_
    numArr.push(num);_x000D_
_x000D_
    //cancat num String_x000D_
    for(let i = 0; i < numArr.length; i++) {_x000D_
        switch(i) {_x000D_
            case 0://M_x000D_
                for(let j = 0; j < numArr[i]; j++) {_x000D_
                    numStr = numStr.concat("M");_x000D_
                }_x000D_
                break;_x000D_
            case 1://D_x000D_
                switch(numArr[i]) {_x000D_
                    case 0:_x000D_
                        _x000D_
                        break;_x000D_
                    case 1:_x000D_
                        if(numArr[i + 1] === 4) {_x000D_
                            numStr = numStr.concat("CM");_x000D_
                            i++;_x000D_
                        }else {_x000D_
                            numStr = numStr.concat("D");_x000D_
                        }_x000D_
                        break;_x000D_
                }_x000D_
                break;_x000D_
            case 2://C_x000D_
                switch(numArr[i]) {_x000D_
                    case 0:_x000D_
                        _x000D_
                        break;_x000D_
                    case 1:_x000D_
                        numStr = numStr.concat("C");_x000D_
                        break;_x000D_
                    case 2:_x000D_
                        numStr = numStr.concat("CC");_x000D_
                        break;_x000D_
                    case 3:_x000D_
                        numStr = numStr.concat("CCC");_x000D_
                        break;_x000D_
                    case 4:_x000D_
                        numStr = numStr.concat("CD");_x000D_
                        break;_x000D_
                }_x000D_
                break;_x000D_
            case 3://L_x000D_
                switch(numArr[i]) {_x000D_
                    case 0:_x000D_
                        _x000D_
                        break;_x000D_
                    case 1:_x000D_
                        if(numArr[i + 1] === 4) {_x000D_
                            numStr = numStr.concat("XC");_x000D_
                            i++;_x000D_
                        }else {_x000D_
                            numStr = numStr.concat("L");_x000D_
                        }_x000D_
                        break;_x000D_
                }_x000D_
                break;_x000D_
            case 4://X_x000D_
                switch(numArr[i]) {_x000D_
                    case 0:_x000D_
                        _x000D_
                        break;_x000D_
                    case 1:_x000D_
                        numStr = numStr.concat("X");_x000D_
                        break;_x000D_
                    case 2:_x000D_
                        numStr = numStr.concat("XX");_x000D_
                        break;_x000D_
                    case 3:_x000D_
                        numStr = numStr.concat("XXX");_x000D_
                        break;_x000D_
                    case 4:_x000D_
                        numStr = numStr.concat("XL");_x000D_
                        break;_x000D_
                }_x000D_
                break;_x000D_
            case 5://V_x000D_
                switch(numArr[i]) {_x000D_
                    case 0:_x000D_
                        _x000D_
                        break;_x000D_
                    case 1:_x000D_
                        if(numArr[i + 1] === 4) {_x000D_
                            numStr = numStr.concat("IX");_x000D_
                            i++;_x000D_
                        }else {_x000D_
                            numStr = numStr.concat("V");_x000D_
                        }_x000D_
                        break;_x000D_
                }_x000D_
                break;_x000D_
            case 6://I_x000D_
                switch(numArr[i]) {_x000D_
                    case 0:_x000D_
                        _x000D_
                        break;_x000D_
                    case 1:_x000D_
                        numStr = numStr.concat("I");_x000D_
                        break;_x000D_
                    case 2:_x000D_
                        numStr = numStr.concat("II");_x000D_
                        break;_x000D_
                    case 3:_x000D_
                        numStr = numStr.concat("III");_x000D_
                        break;_x000D_
                    case 4:_x000D_
                        numStr = numStr.concat("IV");_x000D_
                        break;_x000D_
                }_x000D_
                break;_x000D_
        }_x000D_
    }_x000D_
    console.log(numStr);_x000D_
    return numStr;_x000D_
}_x000D_
_x000D_
convertToRoman(3999);
_x000D_
_x000D_
_x000D_