Critisize Roman Numeral Converter code

Critisize Roman Numeral Converter code
0

#1

Hello everybody,
Please criticize my code:

function convertToRoman(num) {
var tmpnum = num.toString();
var res = ‘’;
if(tmpnum.length > 3){
var num1 = num % 1000;
var num2 = (num - num1)/1000;
res = thousandToRomans(num2) + convertNumsLessThan1000(num1);
} else {
res = convertNumsLessThan1000(num);
}
return res;
}

function convertNumsLessThan1000(num){
var res = ‘’;
var base = [
[‘C’, ‘CC’, ‘CCC’, ‘CD’, ‘D’, ‘DC’, ‘DCC’, ‘DCCC’, ‘CM’],
[‘X’, ‘XX’, ‘XXX’, ‘XL’, ‘L’, ‘LX’, ‘LXX’, ‘LXXX’, ‘XC’],
[‘I’, ‘II’, ‘III’, ‘IV’, ‘V’, ‘VI’, ‘VII’, ‘VIII’, ‘IX’]
];
num = num.toString();
var N = num.length;
var start = 3-N;
for(var i = start; i < 3; i++){
if(num[i-start] !== ‘0’){
res += base[i][parseInt(num[i-start])-1];
}
}
return res;
}

function thousandToRomans(num){
var res = ‘’;
for(var i = 0; i < num; i++){
res += ‘M’;
}
return res;
}

convertToRoman(501);